Assorted Handy vim Commands, Part 1

David Nash vim, xhtml 1 Comment

To reverse the order of lines, eg 1-5
: 1,5 g/^/m0
For example,

one
two
three
four
five

becomes

five
four
three
two
one

To remove blank lines
: %g/^$/d

Delete all lines that don’t contain “string”
: %v/string/d

Comments 1

Leave a Reply

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