How do I reverse the order of all lines in a file using Vim?
:g/^/m 0
This clever use of the :global command reverses every line in the current buffer.
command-line #editing #ex-commands #global #text-manipulation
:g/^/m 0
This clever use of the :global command reverses every line in the current buffer.
command-line #editing #ex-commands #global #text-manipulation
:%s/,/\r/g
In Vim's substitute command, \r in the replacement string inserts a newline.
:%s/\<word\>/\u&/g
Vim's substitute command supports case conversion modifiers in the replacement string.
:%sort u
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
command-line #command-line #ex-commands #editing #text-manipulation #sort
gJ
The gJ command joins the current line with the line below it without inserting any space between them.
:%!column -t
The column -t command formats whitespace-separated text into neatly aligned columns.
command-line #command-line #shell #formatting #text-manipulation