Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 530
Nathan Friend Avatar asked Mar 05 '26 05:03

Nathan Friend


1 Answers

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

like image 191
romainl Avatar answered Mar 06 '26 19:03

romainl



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!