Want to see how many times you used the word very in a file? There are a couple of easy ways.
First, tell
vi
to stop searching when you get to the end of the file. Type the command
:set nowrapscan
or put it in your
.exrc
file (
4.9
)
.
Move to the top of the file with the
1G
command. Search for the first
very
with the command
/very
(HINT: using the
word-limiting regular expression
/\<very\>
(
26.4
)
instead will keep you from matching words like
every
). To find the next
very
, type the
n
(next) command.
When
vi
says
Address
search
hit
BOTTOM
without
matching
pattern
, you've found all of the words.
Use the command:
:g/very/p
The matching lines will scroll down your screen.
To find the line numbers, too, type
:set
number
before your searches.
-