← Back to Upcase

Autocompletion on vim using dotfiles


(Shankar Dhanasekaran) #1

https://github.com/thoughtbot/dotfiles says it can autocomplete but I’m on vim and I couldn’t see any way to trigger autocomplete. what should I do?

Thanks


(George Brocklehurst) #2

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.

(George Brocklehurst) #3

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.


(Jaroslav Janukevic) #4

You can use https://github.com/ervandew/supertab 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 https://github.com/SirVer/ultisnips which integrates out of the box.
You might also want to check out Supertab options for example, you might enjoy

let g:SuperTabDefaultCompletionType = "context"