Inclusive search in vim

I noticed that when I search for a pattern with / in vim, the cursor is dispatched to the next occurrence of the pattern, even if the cursor was in place before searching. How to search for a pattern and keep the cursor stationary if it is already present?

It is possible to avoid the problem by installing wrapscan and using N, but is there an easier way?

+3


source to share


1 answer


With incremental search enabled (through set incsearch

), the next match is highlighted as you type, but the cursor actually only moves when pressed <CR>

. Clicking <Esc>

anytime cancels the search and you are back when you started.



+3


source







All Articles