How do I paste the last Ex command I ran into my buffer?
":p
The : register holds the most recently executed Ex command.
registers #registers #ex-commands #normal-mode #productivity
":p
The : register holds the most recently executed Ex command.
registers #registers #ex-commands #normal-mode #productivity
".p
The ".
registers #registers #editing #insert-mode #normal-mode #productivity
zf / zo / zc / za
Vim's folding system lets you collapse blocks of code into a single line, hiding the details so you can focus on the structure.
editing #editing #folding #navigation #normal-mode #productivity
mA / 'A
Uppercase marks (A-Z) are global marks — they remember not only the line and column position, but also the file where they were set.
navigation #navigation #marks #normal-mode #buffers #productivity
gn
The gn motion searches forward for the next match of the last search pattern and visually selects it.
search #navigation #search #motions #normal-mode #repeat #editing
{N}%
The {N}% command jumps the cursor to the line that is N percent of the way through the file.
qaYp<C-a>q99@a
By recording a macro that duplicates a line and increments its number, you can generate a numbered list of any length with a single replay command.
macros #macros #editing #normal-mode #automation #productivity
"1p then u.u.u.
Vim stores your last 9 deletions (of one line or more) in the numbered registers "1 through "9.
registers #registers #editing #normal-mode #undo-redo #paste
dap / dip
The dap and dip commands use Vim's paragraph text objects to delete an entire block of contiguous text in a single motion.
editing #editing #text-objects #normal-mode #delete #motions
di(
The di( command deletes everything inside the nearest pair of parentheses without removing the parentheses themselves.
` vs '
Vim offers two ways to jump to a mark, and the difference is crucial: the backtick (` `) jumps to the exact line and column where the mark was set, while the si
"=expression<CR>p
The expression register ("=) lets you evaluate any Vimscript expression and paste the result directly into your buffer from normal mode.
registers #registers #editing #normal-mode #productivity #math
qA
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
macros #macros #registers #normal-mode #editing #productivity
cit
The cit command deletes everything between the nearest pair of HTML/XML tags and drops you into insert mode, ready to type the replacement.
ci"
The ci" command deletes everything inside the nearest pair of double quotes and drops you into insert mode, ready to type the replacement.
cis
The cis command deletes the entire sentence under the cursor and drops you into insert mode, ready to type a replacement.
ct{char}
The ct{char} command deletes everything from the cursor up to (but not including) the specified character and drops you into insert mode.
editing #editing #motions #normal-mode #text-objects #productivity
cw vs ciw
The cw and ciw commands both change a word, but they behave differently depending on cursor position.
editing #editing #text-objects #motions #normal-mode #productivity
xp
The xp command swaps the character under the cursor with the character to its right.
<C-w><C-w>
The (Ctrl+w Ctrl+w) command cycles the cursor to the next window in the current tab.