質問

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?

役に立ちましたか?

解決

$ 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 (as) are highlighted everywhere, in both cases.

For more information, see :h range and :h :s.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top