Helpful Vim commands

Winter camp

Vim has a lot of built-in commands that are very helpful. The following table lists commands I tend to use often. However, this is not even the tip of the command iceberg Vim offers.

CommandExplanation
:%s/foo/bar/gReplace all instances of “foo” with “bar”.
:g/foobar/dDelete all lines containing “foobar”.
d$Delete the current line after the marker.
=Auto indent visually marked lines.
5>Indent visually marked lines 5 spaces to the right.
:sort uSort visually marked lines and remove duplicate lines.
:w !sudo tee %Save changes as root.

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *