How do I paste the current filename into the buffer?
"%p
The % register in Vim always contains the name of the current file.
registers #registers #editing #insert-mode #productivity #filename
"%p
The % register in Vim always contains the name of the current file.
registers #registers #editing #insert-mode #productivity #filename
":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
:set undofile
By default, Vim's undo history is lost when you close a file.
:w !{cmd}
The :w !{cmd} command writes the buffer contents to the stdin of an external shell command without modifying the buffer or saving to disk.
command-line #command-line #ex-commands #shell #editing #productivity
:copen / :cnext / :cprev
The quickfix list is Vim's built-in mechanism for navigating a list of file locations — compiler errors, grep results, search matches, or any structured outpu
navigation #navigation #quickfix #ex-commands #productivity #workflow
:%!{cmd}
The :%!{cmd} command pipes the entire buffer through an external shell command and replaces the buffer contents with the command's output.
command-line #editing #ex-commands #shell #filtering #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
<C-k>{char1}{char2}
Vim has a built-in digraph system that lets you insert hundreds of special characters by typing two-character mnemonics.
editing #editing #insert-mode #special-characters #unicode #productivity
<C-r>{register}
Pressing followed by a register name in insert mode inserts the contents of that register at the cursor position without leaving insert mode.
<C-w>
Pressing in insert mode deletes the word before the cursor instantly, without requiring you to switch to normal mode.
{N}%
The {N}% command jumps the cursor to the line that is N percent of the way through the file.
<C-n> / <C-p>
Vim has a powerful built-in completion system that requires zero plugins.
:lopen / :lnext / :lprev
The location list is a per-window variant of the quickfix list.
buffers-windows #navigation #quickfix #ex-commands #windows #productivity
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
q:
The command-line window is a special buffer that shows your entire Ex command history and lets you edit entries using the full power of Vim's normal mode before
command-line #command-line #ex-commands #history #editing #productivity
<C-x><C-l>
The command triggers whole-line completion in insert mode.
:10,20t30
The :t command (short for :copy) duplicates lines from one location to another without touching any registers.
command-line #editing #ex-commands #lines #productivity #ranges
:enew | setlocal buftype=nofile bufhidden=wipe noswapfile
A scratch buffer is a temporary, unnamed buffer that exists only in memory — it won't prompt you to save when you close it and leaves no trace on disk.
buffers-windows #buffers #editing #ex-commands #productivity #workflow