Vim Tips Wiki

Editing

Delete all lines containing a pattern

1
  • The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit. If you are undoing an edit that is …
Latest revision Your text
Line 81: Line 81:
   
 
How would you instead of deleting, replace matched lines with a ''single'' newline between remaining lines?
 
How would you instead of deleting, replace matched lines with a ''single'' newline between remaining lines?
 
Use s/// instead. Make sure your pattern matches the whole line (by using wildcards and/or anchors), and replace it with nothing:
 
:s/.*pattern.*//
 
  Loading editor
Below are some commonly used wiki markup codes. Simply click on what you want to use and it will appear in the edit box above.

View this template