How do I delete all blank lines in a file?
:g/^$/d
The :g/^$/d command deletes every blank line in the file using Vim's powerful global command.
:g/^$/d
The :g/^$/d command deletes every blank line in the file using Vim's powerful global command.
dd
The dd command deletes the entire current line, regardless of where the cursor is positioned on that line.
dit
The dit command deletes the text inside the nearest enclosing HTML or XML tag pair without removing the tags themselves.
D
The D command deletes everything from the cursor position to the end of the current line.
de
The de command deletes from the cursor position to the end of the current word.
"_d
The "d command deletes text using the black hole register ("), which discards the deleted content instead of storing it.
:windo diffthis
The :windo diffthis command activates Vim's built-in diff mode across all visible windows, highlighting the differences between them.
A
The A command moves the cursor to the end of the current line and enters insert mode.
"Ayy
The "Ayy command appends the current line to register a instead of overwriting it.
gg=G
The gg=G command re-indents every line in the current file according to Vim's indentation rules.
:cfdo %s/old/new/g | update
The :cfdo %s/old/new/g update command performs a search and replace across every file in the quickfix list and saves each one.
cgn
The cgn command combines the change operator with the gn motion to change the next occurrence of your last search pattern.
ciw
The ciw command deletes the inner word under the cursor and drops you into insert mode so you can type a replacement.
ci{
The ci{ command deletes everything inside the nearest pair of curly braces {} and places you in insert mode to type a replacement.
ci(
The ci( command deletes everything inside the nearest pair of parentheses and places you in insert mode, ready to type a replacement.
C
The C command deletes everything from the cursor position to the end of the line and places you in insert mode.
diw
The diw command deletes the inner word under the cursor.
.
The .
:%s/old/new/g
The :%s/old/new/g command replaces all occurrences of old with new across every line in the file.
vi"
The vi" command visually selects all text inside double quotes, without including the quotes themselves.
visual-mode #visual-mode #text-objects #editing #normal-mode