Built-In Vim Autocomplete
github.com
github.com
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <tab> <c-r>=InsertTabWrapper()<cr>The great thing is that I was able to do this in less than 100 lines of code, and I love using it myself every day at work. Just goes to show that Vim has a pretty good completion system already and you don't need to use some bloated plugin system like YouCompleteMe or Neocomplete.
(I haven't actually checked yours out, but I assume they're very similar in what they offer)
function! InsertTabWrapper()
let col = col('.') - 1
if !col || getline('.')[col - 1] !~ '\k'
return "\<tab>"
else
return "\<c-p>"
endif
endfunction
inoremap <expr> <tab> InsertTabWrapper()
inoremap <s-tab> <c-n>My vimrc: http://tinyurl.com/mzo7d6l
And a shot: http://tinyurl.com/kjldwy5
Vim-autocomplpop is a fairly old plugin, but it still works just fine. It automatically shows autocompletion options as you type like an IDE. This is very handy.
The only downside is that external autocompletion engines like ctags and rope can sometimes cause performance issues. For example, python.vim uses rope to analyze a file, but that can take a while to initialize and crawl directories if you're editing a file in your home directory. Since it's a plugin written before Vim/Neovim's async code, it tends to make Vim unresponsive, so I only enable vim-autocomplpop on projects I'm working on. This isn't an issue if you use Vim's built-in autocomplete (instead of python.vim). I'll get around to rewriting autocomplpop someday and working on a solution to mitigate external autocomplete providers slowing down Vim.
0: https://github.com/othree/vim-autocomplpop 1: https://github.com/racer-rust/vim-racer
See ':help cpt' and ':help ins-completion'
YouCompleteMe is a good plugin for expanding out autocompletion for a lot more languages, but the built-in autocompletion is remarkably good out of the box.
Additionally, I set the user complete mode (<C-x><C-u>) to use vim's built in syntax complete (`:set completefunc=syntaxcomplete#Complete`), which is super helpful with e.g. config files because Vim is aware of all the available completion options.
Of course there's filename complete too (<C-x><C-f>).
These three modes can get some intelligent completion done but quite frankly the default local keyword completion covers 90% of my use cases.
I think the biggest thing to accept is that you will not be proficient with your editor for quite a long time. I recommend practicing with vim tutorials until it feels reasonably good before taking the plunge entirely. One very important thing is to keep looking for efficient ways to work with it. It's a bit like emacs in that if you ever think, "Oh, this is just painful. There must be a better way", then there is almost guaranteed to be a better way. Stop, find out what it is. Practice it.
My last piece of advice is that vim-style editing is a little bit different that emacs-style editing (at least for me). With emacs, I find that I memorise keybindings and practice using them. With vim, it's much more about the context -- when you are in situation X, you do this kind of thing. So it needs more practice (again IMO). However, once you have your brain oriented (orientated? :-) ), there is this sense of freedom. You are working with larger blocks of abstraction, rather than just the character level. Some people feel this is more efficient (i.e. faster), but I'm not sure. For me it's rather that it is closer to what I'm actually thinking when I'm programming. YMMV and I should warn you again that it takes considerable practice to get to the point where it starts to feel good.
:help new-omni-completion