VIM: Quick autocompletion
This little VIM script enables autocompletion with the tab key. All words in the current file will be used as possible completions. No cross-file autocompletion yet. Put this into ~/.vimrc (or _vimrc in your VIM directory if you are on windows); create the file if it doesn’t exist:
" Autocompletion with <tab>
function InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\</tab><tab>"
else
return "\<c -p>"
endif
endfunction
inoremap <tab> <c -r>=InsertTabWrapper()<cr>