Vim Tip: Use Ctrl-Space for omni and keyword completion.
Having Ctrl+Space for auto-completion is great because its a much more natural binding than the vim defaults.
Sometimes omni completion doesn’t find things properly (such as when searching in the current buffer), so I like to fall back to keyword completion if no results are found in omni-completion.
Put this in your .vimrc to get the same effect:
inoremap <expr> <C-Space> pumvisible() \|\| &omnifunc == '' ?
\ "\<lt>C-n>" :
\ "\<lt>C-x>\<lt>C-o><c-r>=pumvisible() ?" .
\ "\"\\<lt>c-n>\\<lt>c-p>\\<lt>c-n>\" :" .
\ "\" \\<lt>bs>\\<lt>C-n>\"\<CR>"
imap <C-@> <C-Space>
This provides an even more powerful feel to the code completion in vim.








[...] takahe83 wrote an interesting post today onHere’s a quick excerptHaving Ctrl+Space for auto-completion is great because its a much more natural binding than the vim defaults. Sometimes omni completion doesn’t find things properly (such as when searching in the current buffer), so I like to fall back … [...]
Pingback by Vim Tip: Use Ctrl-Space for omni and keyword completion. — June 12, 2008 @ 12:30 am