I would like to list the matches, when I hit:
/example
so that I see where all matches are at once.
In normal mode you can search forwards by pressing / (or <kDivide> ) then typing your search pattern. Press Esc to cancel or press Enter to perform the search. Then press n to search forwards for the next occurrence, or N to search backwards.
One can search forward in vim/vi by pressing / and then typing your search pattern/word. To search backward in vi/vim by pressing ? and then typing your search pattern/word. Once word found in vim, you can press the n key to go directly to the next occurrence of the word in backwards.
Vim offers several commands for searching for files by name: :find, :sfind, :tabfind on the command-line, several normal-mode commands like gf, and others. If you just enter :find filename , Vim will directly open the first file found in your 'path' matching "filename".
:g//p
In its longer form:
:global/regular-expression/print
You can leave out the pattern/regex and Vim will re-use the previous search term.
Trivia: The grep tool was named after this command sequence.
You can also do a :
g/pattern/#
that will print the pattern you want and the number of the line.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With