#vim #g #scripts
POWER OF G!
Add text to the end of a line that begins with a certain string.
Reverse a file (just to show the power of g).
POWER OF G!
Add text to the end of a line that begins with a certain string.
:g/^pattern/s/$/mytext
Delete all lines that do not match a pattern. The commands shown are equivalent (v is "inverse"). :g!/pattern/dMove all lines matching a pattern to end of file.
:v/pattern/d
:g/pattern/m$Reverse a file (just to show the power of g).
:g/^/m0Vim Tips Wiki
Power of g | Vim Tips Wiki | Fandom
The global command :g is very useful. Here are some examples showing the power of :g. :[range]g/pattern/cmd This acts on the specified [range] (default whole file), by executing the Ex command cmd...