Written December 16, 2014. Tagged Vim.
Say you have this file open in Vim:
one();
console.log("about to do two");
two();
console.log("did two");
three();
console.log("about to do four");
four();
console.log("did four");
The logging helped you figure out an issue and now you want to be rid of the console.log
lines.
There's (not surprisingly) a quick way to do that in Vim:
:g/log/d
Any line matching the Vim regular expression /log/
will be removed.
More generally, :g[lobal]
runs the given Ex command on the matching lines. In this case, the command is :d[elete]
.
For more details, see :help :g
.
I've only used this to remove lines, but it has all sorts of applications.