How do I go to the first search result in a file?
ggn
will bring you to the first instance of your search in the file -- the gg
brings you the beginning of the file and the n
goes to the next match of your pattern.
You can also use gg2n
to go to the second instance in the file, or gg42n
to go to the forty-second instance. You can similarly use G$N
to go to the final match (G
brings you to the final line, $
brings you to the end of that line, and N
searches backwards), or G$2N
to go to the penultimate one.
Obscure Ex commands for the win:
:ij[ump] foo "jumps to first foo that is not in a comment
:ij[ump]! foo "jumps to first foo, comment or not
See also :il[ist]
.
Use the gg
command to navigate to the beginning of the file.
gg
/foo