inman320
inman320

Reputation: 501

mapping the 'n' key in vim while not searching

Is it possible to map over the 'n' and 'N' keys without overriding the time they're used for skimming search results?

Upvotes: 2

Views: 342

Answers (2)

mike3996
mike3996

Reputation: 17497

Basically you could be searching for something any given time, so remapping n in normal mode without modifications would override the skimming.

After a little considering, if you always quit your searchings with <C-l> (clearing the highlights, I'm not sure if that is the default), you could indeed do something like this with a few extra helper functions:

/,?,*:
 --> set s:searching = true
     and do the builtin things

<C-l>:
 --> set s:searching = false
     and do the builtin things

n,N:
 --> if s:searching then use the builtin n
     else activate your own functionality 

Upvotes: 2

Diego
Diego

Reputation: 17140

Yes you can map a key in a certain mode. You could read over the documentation for map for all of the available options to fine tune your mappings.

Specifically, the map-overview for a list of the mappings and what mode they are used in.

Upvotes: 0

Related Questions