0
How can you remove given lines efficiently in Vim?
I want to remove all lines which match this
:g!/div/
I unsuccessfully ran:
:g!/div/s/^*//g
0
How can you remove given lines efficiently in Vim?
I want to remove all lines which match this
:g!/div/
I unsuccessfully ran:
:g!/div/s/^*//g
7
To remove all lines that match div
:g/div/d
To remove all lines that don't match div
:g!/div/d
6
:g!/div/d
Works just fine to do what you want.
2Vim certainly isn't only used on servers. Potentially anyone who does any programming could benefit from this question. I certainly did, and I'm not affiliated at all with servers in my work. – None – 2009-08-20T23:27:25.007
2@thr4wn: superuser isn't the site for servers, that's serverfault. – John Millikin – 2009-08-20T23:28:22.680
1
:V/div/d
In case of larger files, it might be faster to:
:%!grep div
All I know is that I use the 'dd' command to remove a line – Joe Phillips – 2009-08-20T23:10:48.097