Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When I search in vim and then press “esc” cursor returns to previous position

Tags:

vim

Something has seemingly happened to my vim install, and I'm not exactly sure what. I'm a long time vim user (although I don't use it as a main editor).

When I search:

/foo

I want to edit the location that it found, so I press ESC (in preparation for getting into insert mode). vim now jumps BACK to where I started from in the file. E.g. if I was on line 0 of a 3000 line file, I search for a particular string, find it at line 1700, and want to edit it - ESC takes me back to line 0.

What's going on? Did I accidentally set some strange mode? Or did I forget a hotkey combination that I should know?

like image 888
fridgepolice Avatar asked Oct 28 '25 01:10

fridgepolice


1 Answers

This is the expected behaviour with the incsearch option on:

Note that the match will be shown, but the cursor will return to its
original position when no match is found and when pressing <Esc>.  You
still need to finish the search command with <Enter> to move the
cursor to the match.

If incsearch is not on then the cursor doesn't jump to the first match at all, it doesn't move until you press <Enter>.

like image 160
Jonathan Wakely Avatar answered Oct 31 '25 02:10

Jonathan Wakely



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!