For years I unknowingly used some, shall we say, deviant distribution of vim that would stay at the location of the highlighted search result after hitting <Esc> in the middle of a search instead of jumping back to the original position.

I've tried for more than a year now to forget that muscle memory, but I cannot for the life of me stop pressing <Esc> once what I've typed in the search has taken me to the position I'm searching for.

Does anyone know a) how I can get that behavior back, b) what *nix distribution had a copy of vim that defaulted to this behavior?

  • 2
    If you use enter instead of esc it should work out of the box. – Christian Brabandt Jul 20 '17 at 22:44
  • @ChristianBrabandt like I said, I've tried teaching myself to do that. Muscle memory. – Mahmoud Al-Qudsi Jul 20 '17 at 22:45

There is an option for this: set cpoptions+=x

From :help cpo-x

    x   <Esc> on the command-line executes the command-line.
        The default in Vim is to abandon the command-line,
        because <Esc> normally aborts a command.  |c_<Esc>|

It is also the default vim behavior when compatible is set, and is the behavior of vi in distributions that ship the "real thing," such as Arch Linux.

  • That might indeed be it. And since I never use <ESC> to abandon the command line (ctrl+c only), this would probably fit the bill! – Mahmoud Al-Qudsi Sep 19 '17 at 2:29

I don't think you can configure this in VIM (see help incsearch) but


may be an option (if it's not already included you could ask for or implement that feature).

  • I already use it :( – Mahmoud Al-Qudsi Jul 20 '17 at 22:45
  • Why don't you open an issue or PR? – laktak Jul 21 '17 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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