Nathan Friend
Nathan Friend

Reputation: 12834

Visual Studio-like autocomplete in Vim

Coming from Visual Studio, I've grown accustomed to having automatic autocomplete when I type a non-alphanumeric character:

Autocomplete in Visual Studio

At this point in time, if I press space (or ), ;, etc.), Visual Studio will assume I want public and will insert it for me.

I'd like this functionality in Vim. The default autocomplete is close (pressing Ctrl+P while in Insert mode), but I'd like to have the autocomplete dropdown open automatically.

I tried out the AutoComplPop plugin, which pops open the options dropdown automatically, but also requires the user to press Enter to actually insert the selection:

AutoComplPop autocompletion

Is there a plugin that provides Visual Studio-style autocomplete functionality? Or is there a way to configure Vim's default autocomplete to behave in this manner?

Just to be clear, I'm not asking about the suggestions provided by Vim's autocomplete (I've found plenty of documentation about adding custom dictionaries), but rather the mechanics of the autocomplete itself.

Upvotes: 3

Views: 2600

Answers (2)

romainl
romainl

Reputation: 196826

Unlike <Down> and <Up> which only move down and up the popup menu, <C-n> and <C-p> also insert the selected suggestion so you can just keep typing (a <space>, a .…) without having to press <CR>.

For what it's worth, I've forked AutoComplPop to add PHP and JavaScript support and just hacked in support for the kind of interaction you want.

acp-forked in effect

Upvotes: 1

yemu
yemu

Reputation: 28309

Fear not citizens, enter YouCompleteMe: finally a good, intelligent code completion plugin for Vim. It's free, fast and will save you lots of time. Couple YouCompleteMe with Supertab and you'll be even more of a coding machine than you already are in Vim. source

https://github.com/Valloric/YouCompleteMe

Upvotes: 0

Related Questions