1

I search with /, press enter, and go a few results down using n. I realize that I have gone a few more results down than I meant to and want to go back a few. I press m because that is next to n just like k is next to j. Nothing happens because m is not N.

How can I remap N to m in the context of navigating search results?

Edit: I am using neovim in case that makes a difference ;)

  • Welcome to Vi and Vim! Interesting question. Do you want to remap N to m only when searching or all the time? – D. Ben Knoble Aug 19 at 12:27
  • Ideally only when searching. I was not aware that it had a function outside the search context (I only started using vim regularly last week). Does it? :help n goes to the search help. – Isaac Ball Aug 19 at 12:38
  • 3
    Ok. It marks, actually, which is a nice feature. I’m not sure vim can tell when it’s searching explicitly (bc you can search, navigate, edit, save the file, whatever, and whenever you hit n again it picks up the search), so ultimately answers will probably be « You can do it permanently, but this overrides the mark feature which is useful ». I’ll try to write one at some point – D. Ben Knoble Aug 19 at 12:41
  • Interesting, thanks for the clarification @D.BenKnoble – Isaac Ball Aug 19 at 12:46
  • 1
    Agreeing with @Ben here: You should get used to use N and not try to remap it to m for several reasons: If you remap it permanently you loose the mark feature, if you remap it "only when searching" it will be hacky (probably buggy), non trivial to implement and with very few (or none) added value. A good rule of thumb when starting to use Vim is: Don't remap an existing feature (e.g searching backward) only remap something which can't be done out of the box (e.g. center the next search result in the middle of the screen). That allows you to get used to vanilla vim which is good. – statox Aug 19 at 15:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.