Live data from Hacker News

Built-In Vim Autocomplete

github.com

11–20 of 30 posts

Re: Built-In Vim Autocomplete

#11
post #7

What is xctrl?

You mean `Ctrl-xCtrl-f`? That's `Ctrl-x Ctrl-f`. In terms of how it parses, after `Ctrl-`, the next token must be a single character (a key) is accepted. So `Ctrl-x` completes that particular accord and `Ctrl-f` is the accord following it.

Re: Built-In Vim Autocomplete

#13

Vim's autocomplete is alright, but it can definitely be super-charged by plugins like vim-autocomplpop[0], superTab, and language specific plugins like vim-racer[1]. 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…

Have you tried YouCompleteMe? I'm surprised you didn't mention it.

YCM is really painful to set up, but once it's running, I found myself unable to go back to anything else (even deoplete). It's auto completion for C++ based on the cmake configuration is extremely powerful.

Re: Built-In Vim Autocomplete

#14

Earlier quoted context omitted.

Have you tried YouCompleteMe? I'm surprised you didn't mention it.

YCM is really painful to set up, but once it's running, I found myself unable to go back to anything else (even deoplete). It's auto completion for C++ based on the cmake configuration is extremely powerful.

It works surprisingly well for languages like JavaScript and rust as well.

Re: Built-In Vim Autocomplete

#15

Vim's autocomplete is alright, but it can definitely be super-charged by plugins like vim-autocomplpop[0], superTab, and language specific plugins like vim-racer[1]. 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…

Have you tried YouCompleteMe? I'm surprised you didn't mention it.

I've used YCM quite a bit in the past, but I haven't had it installed on my new laptop (Dell XPS 13). It uses racer for Rust and Jedi for Python, both of which I already use. I should look into it again.

Re: Built-In Vim Autocomplete

#16
post #6

Here is a way to bind autocomplete to TAB such that you still get TAB unless you are at the end of a word to complete. It's super convenient. function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\ " else return "\ " endif endfunction inoremap =InsertTabWrapper()

I made a plugin [1] similar to this which offers more options when you press the Tab key. For instance, if you're typing a file path, you get Ctrl-X Ctrl-f completion (vim's file path completion) instead of the regular keyword completion. And if you type a period (configurable) and press Tab in filetypes like C, Python, Ruby, etc, you get omni completion (vim's semi-intelligent completion, which offers methods on classes, looks in ctags files, etc).

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.

[1]: https://github.com/ajh17/VimCompletesMe

Re: Built-In Vim Autocomplete

#18
post #6

Here is a way to bind autocomplete to TAB such that you still get TAB unless you are at the end of a word to complete. It's super convenient. function! InsertTabWrapper() let col = col('.') - 1 if !col || getline('.')[col - 1] !~ '\k' return "\ " else return "\ " endif endfunction inoremap =InsertTabWrapper()

I got that one some time ago from https://github.com/garybernhardt/dotfiles/blob/master/.vimrc... which offers several other useful functions and settings.

Re: Built-In Vim Autocomplete

#19
Long time emacs user here. I had an aha moment yesterday, when after several months of using God mode I said "I should rebind C-t to generic transpose and use a follow-up key to specify char, word, sexp, etc." If I understand correctly, this is sort of how VIM works. I want to try EVIL now. Anyone here that's made the switch in this direction and can talk about it?
Post reply on HN