andrew
andrew

Reputation: 1243

Is there a way to change the behavior of the vim omnicomplete menu?

Omnicompletion is working, but it automatically inserts the first result.

What I'd like to do is open the omnicomplete menu, then be able to type to narrow down the results, then hit enter or tab or space or something to insert the selected menu item.

Is this possible?

Upvotes: 15

Views: 3922

Answers (4)

Alexey Romanov
Alexey Romanov

Reputation: 170899

set wildmenu
set wildmode=list:longest,full

Found here. There is also a great plugin for all of your completion needs called SuperTab continued.

Upvotes: 3

orestis
orestis

Reputation: 17200

The command you are looking for is:

:set completeopt+=longest

It will insert the longest common prefix of all the suggestions, then you can type and delete to narrow down or expand results.

Upvotes: 17

Ali Afshar
Ali Afshar

Reputation: 41667

This is the general Vim completion behaviour. For a complete overview, you can do

:he compl-current

But for your specific case (which you require the completion to be in state 2 or 3 (described in the document above). You can simply use Backspace, or Control-H to jump from state one to state two. In state 2 you can narrow the search by typing regular characters. So to complete completion with narrowing:

compl<C-X><C-P><BS>letion

It is totally backwards, I know, but that's how it works.

Edit: You can use the Down arrow key too isntead of Control-H or Backspace, and it has the benefit of not deleting a character.

Upvotes: 0

VonC
VonC

Reputation: 1329092

This plugin might do what you are after: autocomplpop

Or you can try and make Vim completion popup menu work just like in an IDE.

Upvotes: 0

Related Questions