N VIM Command

How to use N Command in Linux VIM editor?

Explanation


N command is used to find the previous occurrence of searched string. After a string is searched the cursor will be focused on the first occurrence of the string from the current position, to move the cursor to the previous occurrence we can use this command.

Usage:

N

Example:

  • Open the file test.txt using the command
    $ vim test.txt
  • We can notice the following text in the file.
    Hiox India Vim Tutorial Hscripts
    India is seventh largest country in world
    I love India, I'm proud to be an Indian

  • Search of letter India is done using this command
    Enter /India
  • The cursor will point to the first occurrence of the string from the current position.
    N Vim Command
  • To move the cursor to the previous occurrence using the command
    Press N
    Find Previous Occurrence of Searched String Vim

Ask Questions

Ask Question