How do I delete the word before the cursor 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.
Search Vim Tricks
Searching...<C-w>
Pressing in insert mode deletes the word before the cursor instantly, without requiring you to switch to normal mode.
:'<,'>s/\n/, /g
Vim's J command joins lines with a single space, but sometimes you need a custom separator like a comma, pipe, or semicolon.
editing #editing #ex-commands #visual-mode #substitution #lines
{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
"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.
:v/pattern/d
The :v command (short for :vglobal) is the inverse of :g — it executes a command on every line that does not match the given pattern.
command-line #editing #ex-commands #search #filtering #productivity
` 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
:.!sh
The :.
command-line #editing #ex-commands #shell #filtering #productivity
<C-r>=
The expression register (=) lets you evaluate Vimscript expressions on the fly and insert the result directly into your text.
registers #editing #insert-mode #registers #productivity #math
"=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
<C-x><C-f>
The command triggers filename completion in insert mode.
editing #editing #insert-mode #completion #file-management #productivity
autocmd FileType {lang} setlocal {options}
Vim's autocmd FileType lets you apply settings that only take effect when editing a specific file type.