fyusuf-a
fyusuf-a

Reputation: 255

Inclusive search in vim

I remarked that when I search for a pattern with / in vim, the cursor is sent to the next occurence of the pattern, even if the cursor was on an occurence before the search. How can I search for a pattern and have the cursor be still if it is already on an occurence ?

One can avoid the problem by setting wrapscan and using N, but is there an easier way ?

Upvotes: 3

Views: 217

Answers (1)

romainl
romainl

Reputation: 196546

With incremental search enabled (via set incsearch), the next match is highlighted as you type but the cursor is actually moved only when you hit <CR>. Pressing <Esc> at any time cancels the search and you are back were you started.

Upvotes: 3

Related Questions