Autocompletion on vim using dotfiles says it can autocomplete but I’m on vim and I couldn’t see any way to trigger autocomplete. what should I do?


Vim has some built-in completion features that you can use without adding anything your .vimrc. In insert mode:

  • Ctrln and Ctrlp will complete the current word using variable and method names from other open buffers.
  • CtrlxCtrll (i.e. keep holding Ctrl while you hit x and then l in turn) will complete a whole line.

I just had another look through the thoughtbot .vimrc, and in addition to the built-in vim features it maps Tab to Ctrlp, unless you’re at the start of a line: if you are at the start of a line you can use Tab to indent, but if you’re not then Tab will complete the word you’re typing.

You can use and put this into your .vimrc

autocmd FileType ruby,eruby set omnifunc=rubycomplete#Complete
autocmd FileType ruby,eruby let g:rubycomplete_buffer_loading = 1
autocmd FileType ruby,eruby let g:rubycomplete_rails = 1
autocmd FileType ruby,eruby let g:rubycomplete_classes_in_global = 1

Then you can also install which integrates out of the box.
You might also want to check out Supertab options for example, you might enjoy

let g:SuperTabDefaultCompletionType = "context"