Good day,
I have found a strange quirk in Vim that I can’t explain the cause of, so I will describe it to the best of my abilities.
If there is a word that appears multiple times in a file I am editing, I can highlight all instances of it by moving the cursor over the word, and hitting the pound key (ie: SHIFT+3 ==> #). I can then navigate to the next occurrence of this word by hitting ‘N’ (ie: SHIFT+n), and the previous instance by hitting ‘n’.
However, if I perform a search for a word (eg: “int”) by using the search command (ie: /int), using ‘N’ searches backwards, and ‘n’ searches forwards, resulting in opposite mappings compared to when I use the # key. Is there something I’m doing wrong? I’m using a minimalist VIMRC at the moment.
Thank you.
No, it’s correct.
/searches forward,?backwards (similarly*searches for cword forwards and#backwards). Andnredos the search in the same direction andNthe opposite direction. It’s relative to the initial search method.