I notice a different behavior in command line completion from the regular completion in a buffer. Usually even if I select and item from the completion menu, CTRL-E cancels the completion and reverts whatever text was inserted due to it. However that's not the case for me in command line completion. There if I press CTRL-E the suggestion list closes but it also leaves whatever text was selected last. I want to be able to leave completion while keeping the original text I have entered before it.

1 Answer 1


The insert mode completion menu and the command-line completion menu are two different beasts. They behave differently in many ways, in particular a keystroke to cancel completion and return to the original word is only available in the insert mode completion menu.

The insert mode completion menu is typically invoked with Ctrl+P or Ctrl+N (or some of the more specialized keys looking at filenames, tags, etc.), it is displayed vertically close to where the cursor is inserting text, and the Ctrl+E keystroke is available to cancel completion.

The command-line completion menu (invoked by Tab, or whatever 'wildchar' is set to), is typically displayed horizontally and uses different keystrokes or key bindings than the insert completion menu.

The command-line completion menu doesn't really have any key binding to cancel completion and return to the original word. In fact, Vim help on command-line completion is quite specific on that point, as this snippet shows:

When repeating 'wildchar' or CTRL-N you cycle through the matches, eventually ending up back to what was typed. If the first match is not what you wanted, you can use <S-Tab> or CTRL-P to go straight back to what you typed.

So, short of cycling back to the start or cycling all the way to the end, there's no other way to cancel and go back to the text before completion started in command-line completion.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.