Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vim omni completion: continue typing to select desired item

Consider the scenerio when I have typed:

file.f

When I type Ctrl-XCtrl-O the omni-completion popup is shown and the first item is selected. This is what I see:

file.fileno
       ---------
       fileno()  <-- highlighted
       flush()
       ---------

Notice that the text that I have typed ("file.f") has already changed to:

file.fileno

I can move selection down in the list to 'flush', press ENTER and it will end up with

f.flush()

But I would like to continue typing the desired method name instead of using arrow keys. I.e. I would like to type "file.f", "Ctrl-X Ctrl-O", "l" and get either

file.fileno
       ---------
       flush()
       ---------

or

file.fileno
       ---------
       fileno()
       flush()  <-- highlighted
       ---------

Is this possible? Maybe some omni-completion settings have to be changed, or I should use a different keys combination instead of Ctrl-XCtrl-O?

like image 497
alex2k8 Avatar asked Jan 25 '11 23:01

alex2k8


1 Answers

Add: set completeopt+=longest to your .vimrc file.

This will tell omnicomplete to only insert the longest common text of all the matches.

For more information, run the command :help completeopt while in vim.

like image 111
cledoux Avatar answered Nov 04 '22 10:11

cledoux