Deleting lines and non-matching lines with VIM

digg this!| | Comments (0) | TrackBacks (0)

I'm always forgetting how to do this but here's how to delete matching lines:

:g/.*foo.*/d
And the more difficult thing to do that vim makes easy is deleting non-matching lines.  All you do is negate the pattern:
:g!/.*foo.*/d
Daily Vim: Text Editor Tips, Tricks, Tutorials, and HOWTOs: Delete Lines Matching Keyword




0 TrackBacks

Listed below are links to blogs that reference this entry: Deleting lines and non-matching lines with VIM.

TrackBack URL for this entry: http://juxtaposition.axley.net/blog-bin/mt-tb.cgi/2289

Leave a comment

March 2011

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

«« December 2010

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Archives

Contact: Jason Axley

Search Amazon:

Amazon Logo
Powered by Movable Type 4.1