Question

I am learning vim with omnicomplete. I am wondering whether I can show the omnicomplete list without autocompleting current text. For example,

If I type "str.c" and then invoke omnicomplete, it will show a list containing possible words starting with "c", and autocomplete the current text to, say "capitalize".

enter image description here

If, for example, the method I am looking for is count, I have to scroll all the way down the list to find it, or delete the "apitalize" part, and then type o, etc. Is it possible to just show the list, so that if I invoke it after c, it will show the list without autocompleting to capitalize? For example to something like below, where I can still type o to quickly go to count

enter image description here

Was it helpful?

Solution

Thanks to @romainl comment, I looked up completeopt, and I found the answer Make Vim completion popup menu work just like in an IDE. It has a bunch of other related tips. To make the behaviour as described in the question,

:set completeopt=longest,menuone

OTHER TIPS

You can also just stick with the basic vim functionality, and use C-e while in completion to have vim remove the list and go back to the point you initiated the completion.

Alternatively, you can press <C-P> right after <C-X><C-O> to go back to what you typed while keeping the completion menu open.

Check out :h ins-completion-menu for more information.

I think that the initial problem was the lack of noinsert in completeopt option.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top