There is a Vim plugin that does this called SuperTab. However it did not work for me at the beginning. Turns out this is because of one setting line in my .vimrc, which was copied from here in order to have Vim works with R. The evil line is:
After removing that, tab completion works for keyword. This means if I have written a variable name aefearw before, when I type aef and press Tab, Vim will suggest me that word.set paste " turns on traditional pasting of text
This is not enough, I also want language-specific autocompletion (e.g. R function names). There is a setting in SuperTab that can chain autocompletion, detailed here (at the end of documentation). I copy the two blocks of code from there to my vimrc. It seems to work now except that it still doesn't recognize path. If I remove the second path of the codes below then it does recognize path but not R function names. Will investigate more later. Meanwhile this is good enough.
autocmd FileType *
\ if &omnifunc != '' |
\ call SuperTabChain(&omnifunc, "<c-p>") |
\ call SuperTabSetDefaultCompletionType("<c-x><c-u>") |
\ endif
let g:SuperTabDefaultCompletionType = 'context'
autocmd FileType *
\ if &omnifunc != '' |
\ call SuperTabChain(&omnifunc, "<c-p>") |
\ endif
No comments:
Post a Comment