Reputation: 491
What is a simple way to do a visual select on the item I searched for in Vim?
I would like to map my n key to not only go to the next search item but also select it. Similarly for p, * and #.
Looking this up gave me answers to searching for selected items, but I want to select searched items.
Upvotes: 2
Views: 148
Reputation: 53614
You can try something like
nnoremap ,n //b<CR>v//e<CR>
vnoremap ,n <Esc>//b<CR>//e<CR>n
. This does not work for one-character matches. For *
it will look like this:
nnoremap ,* *v//e<CR>
. None of the solutions work with one character matches, you may try adding h
before //e
, but this won’t work at the start of the line. I would not suggest to remap default keys due to the mentioned problems.
Upvotes: 2