How do I duplicate a line in Vim?
yyp
The yyp command duplicates the current line by yanking it and immediately pasting it below.
yyp
The yyp command duplicates the current line by yanking it and immediately pasting it below.
"ap, edit, "ayy
Vim stores macros in registers, which means you can paste a macro's contents into a buffer, edit it as regular text, and yank it back into the register.
:set spell
The :set spell command activates Vim's built-in spell checker, which highlights misspelled words directly in your buffer.
:syntax on
The :syntax on command enables syntax highlighting in Vim, colorizing your code based on the file type.
:g/pattern/normal dd
The :g/pattern/normal {commands} command executes normal mode keystrokes on every line in the file that matches the given pattern.
:g/pattern/command
The :g/pattern/command (global) command executes an Ex command on every line in the file that matches the given pattern.
g<C-a>
The g command increments numbers across a visual selection so that each subsequent line gets a progressively higher value.
:%s/pattern//gn
The :%s/pattern//gn command counts how many times a pattern appears in the file without making any changes.
daw
The daw command deletes a word including one side of its surrounding whitespace.
: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.