Ashot
Ashot

Reputation: 10979

Vim, how to change the default behaviour of * key?

When I press * button on a word, vim searches it and moves cursor to the beginning of next match of that word. How can I change this functionality in such way: when I press * to a word, it searches for it, colors the matched words, I can move to next word by pressing n, but it does not automatically move cursor to the beginning of next match. I just need vim to color the word on which I press * and to navigate on next and previous matches of that word using n and N.

Upvotes: 0

Views: 179

Answers (2)

david
david

Reputation: 6129

I prefer that behaviour too. I've had this in my vimrc for ages:

noremap * *N
noremap # #N

# works the same as * but in reverse

Upvotes: 2

Ingo Karkat
Ingo Karkat

Reputation: 172698

I also prefer it that way. You can use my SearchHighlighting plugin or one of the alternatives listed on the plugin page.

Upvotes: 1

Related Questions