Some time ago I read about an option that fixes the behavior the 'n' and 'N' keys cause when continuing a search in vim. That is, by default 'n' performs a forward search if the search was triggered with '/' but a backward search if the search was triggered with '?'. With this option set 'n' would continue searching towards the end of the document irrespective what search mode I am in. Similarly, 'N' would unconditionally search towards the beginning of the document.

I've tried to find the reference or really any hint as to how this option is called but I was unsuccessful. Does anybody have an idea what I am referring to? It is possible that this option is actually specific to neovim. I don't recall this detail.


1 Answer 1


This is what / and ? do without an argument. If n and N could be configured to do that, it might be considered redundant. There's an extra keystroke (the <return>), but the functionality is complete:

  • /term<return> - search forward for term
  • ?term<return> - search backward for term
  • /<return> - continue searching forward
  • ?<return> - continue searching backward
  • n - continue searching in same direction
  • N - continue searching in opposite direction
  • 1
    Thanks both of you for your help. I went with vim nnoremap <expr> n (v:searchforward ? 'n' : 'N') nnoremap <expr> N (v:searchforward ? 'N' : 'n')
    – deso
    Commented Jun 16, 2017 at 14:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .