Search code examples
vim

How to discard the completion suggestion


I've just changed my 'completeopt' setting back from:

set completeopt = preview,menuone,longest

to the default:

set completeopt = preview,menuone

After a long while of using it as it was, I have decided that I prefer having the first entry selected by default.

I do have one annoyance though. I would like to be able to try to complete, if the match I'm looking for isn't in the list then discard the suggested completion and revert to my original text. How is this done?

I seem to remember from a distant past that this behaviour exists but randomly bashing buttons hasn't proved fruitful and searching isn't working out for me.


Solution

  • You can always type Ctrl-E to return to the original text.

    Furthermore, Ctrl-N/Ctrl-P will eventually cycle back to the original text.

    See: :help completion for more details:

    When completion is active you can use CTRL-E to stop it and go back to the originally typed text. The CTRL-E will not be inserted.