Thursday, July 13, 2006

Delete lines matching a pattern in vim

I have only recently started using the powerful :g
Syntax :[range]:g//[cmd]

Some examples of its usage:

Delete all lines matching a pattern
:g//d

Delete all blank lines
:g/^\s*$/d

I also found this tip in the vim website, which contains a lot more examples:
http://www.vim.org/tips/tip.php?tip_id=227

No comments: