Friday, January 16, 2009

Vim hints: word completion or line completion

I often missed the IDE {word|command|line} completion short-cuts in vim until I found these:

" Line completion: in 'insert mode' it provides you with 
" a list of existing lines to choose from in your current 
" file. 
ctrl-x ctrl-l 

" Word completion: in 'insert mode' it provides you with
" a list of possible matching words starting with the 
" next word available in your current file.
ctrl-n

" Word completion: in 'insert mode' it provides you with
" a list of possible matching words going back from the 
" current word in your current file.
ctrl-p

" Searching a dictionary for word completion is done by 
" first setting the dictionary to search:
:set dictionary=/usr/share/dict/words

" Then try to match a word with:
ctrl-x ctrl-k