Question

I'd like to know if it's possible to content assist script languages like Ruby or JavaScript in Vim.

If it is possible, how can I do that?

Do I have to compile the vim source to turn on the 'rubyinterp' option?

Était-ce utile?

La solution

What you call "content assist" (Eclipse background?) is called "Omni completion" in Vim. It is part of a larger family of completions simply called "Insert mode completion" and you can read all about it in :h ins-completion.

There are two big differences with most IDEs completion mechanisms, though:

  • Vim's built-in completion mechanism can't be automatic: you need to press specific shortcuts for the completion menu to appear. If you want automatic completion, you'll need a plugin: NeoComplCache, SuperTab, AutoComplPop or the younger YouCompleteMe. There are others, so try vim.org.

  • Vim doesn't "understand" your language like IDEs do. Vim is a generic text editor geared toward programming but it doesn't have the ability to parse your code and really understand what you mean or follow your scope or dependency tree. Because of that, completion may be a little fuzzy. So don't get your expectations too high.

You don't need anything special to complete JavaScript but, AFAIK, Vim must be compiled with Ruby support to provide Ruby completion. How to get a proper Vim build depends on your platform, which we don't know.

In both languages, hitting <C-x><C-o> (in insert mode) after method_name. should open a completion menu that works more or less like those in other editors/IDEs.

Autres conseils

Yes, at least to some extent.

Enabling rubyinterp will require recompilation unless you can find a binary that has it. You'll find more on the subject here.

Code-assist can be achieved by usage of plugins and vim's native functionality called (omni-)completion. There are many plugins for the job, but one of my favourites is Neocachecomplete. Or try on one of the vim 'distributions' like the one made by Steve's Francia.

Also you can add custom syntax files that extend support for your language of choice. You can also find plugins that check syntax eg. syntastic.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top