Global command
:[range]g/{pattern}/[command]
:g/foo/d |
Delete lines containing foo |
:g!/foo/d |
Delete lines not containing foo |
:g/^\s*$/d |
Delete all blank lines |
:g/foo/t$ |
Copy lines containing foo to EOF |
:g/foo/m$ |
Move lines containing foo to EOF |
:g/^/m0 |
Reverse a file |
:g/^/t. |
Duplicate every line |
Comments