Vim resources
Tabs
Just like any browser, you can also use tabs within Vim. This makes it incredibly easy to switch between multiple files while you’re making some code changes instead of working in one single file, closing it, and opening a new one. Below are some useful Vim commands for using tab pages:
:tabedit file - opens a new tab and will take you to edit “file”
gt - move to the next tab
gT - move to the previous tab
#gt - move to a specific tab number (e.g. 2gt takes you to the second tab)
:tabs - list all open tabs
:tabclose - close a single tab
Fuente: How to Delete Lines in Vim / Vi
Deleting lines containing a pattern
Syntax
:g/<pattern>/d
- The global command (
g) tells the delete command (d) to delete all lines containing the<pattern> - To match the lines not matching the pattern, add an exclamation mark (
!) before the pattern:
:g!/<pattern>/d
Examples:
:g/foo/d- Delete all lines containing the string “foo”. It also removes line where “foo” is embedded in larger words, such as “football”.:g!/foo/d- Delete all lines not containing the string “foo”.:g/^#/d- Remove all comments from a Bash script. The pattern^#means each line beginning with#.:g/^$/d- Remove all blank lines. The pattern^$matches all empty lines.:g/^\s*$/d- Remove all blank lines. Unlike the previous command, this also removes the blank lines that have zero or more whitespace characters (\s*).