Reputation:
Instead of typing:
:%s/a/b/g
I accidentally typed:
:$s/a/b/g
Then Vim highlights all "a".
I then tried:
:%s/a/
It also highlights all "a"s, but if I run the command again, it says "a" is not found.
So what is the proper use of :$s
?
Upvotes: 0
Views: 173
Reputation: 40879
$
in this case refers to a range. The command :$s/a/b/g
performs the replacement only on the last line of the file, however matches (a
s) are highlighted everywhere, in both cases.
For more information, see :h range
and :h :s
.
Upvotes: 6