:s
(:substitute
) is one of the first commands any Vim user learns. There are several similar commands that are more generic. Like :s
, these commands can take a range; however, unlike :s
, there is no %
variant, as these commands are global by nature.:g
(:global
):v
(:vglobal
) (equivalent to :g!
):g
, but targets strings that do NOT match.g/pattern/_d
puts deleted lines in the null register, which has no performance cost.y a
, each yank would overwrite the previous yank.:norm
:exe
:norm
, you might notice that you can't insert linebreaks -- and <CR>
is literally printed as the strings "\r" and "". :exec(ute)
lets us actually pass in commands as strings to be executed, like eval()
."norm!"
and "A\r"
to the pattern. Before execution, the second is evaluated to "append carriage return."