views:

31

answers:

1

Hey guys, after using graphical IDE's like Visual Studio, I'm used to pressing CTRL+Space to auto-complete a variable or function name. Now, I know such a thing isn't completely possible in VI, but I heard there was a list of commands that could be mapped that allowed automatic completion of variables and functions in the current file opened. Does anyone know what this sequence is?

Thanks in advance.

A: 

Just noticed that you said "vi"; I hope that "vim" is also okay.

It depends on the particular programming language, but in general, the magic word is Omnicomplete.

Put this into .vimrc:

filetype plugin on
set ofu=syntaxcomplete#Complete

Press Ctrl+N or Ctrl+P to trigger the completion. This is insanely customizable; you might like the tips here that make it work more like other IDEs.

Thomas
Well, thanks for the answer but unfortunately my workplace only supports VI which doesn't support Omni :(
IllustratedInsomnia
If I were forbidden from using vim, I would look for another job. If I were forbidden from using vim, but using vi was allowed, I would probably explode at my boss, get escorted out of the building, then look for another job.
Matt Briggs
I don't understand how you get into such a situation. If you're used to Visual Studio, you're a programmer. I can see how a sysadmin might be required to use vi because it's tiny and ubiquitous and he just needs to tweak a few config files, but---programming? And they won't even allow vim?
Wang