How do I collect all lines matching a pattern into a register without leaving them in place?
Using :g/pattern/d A you can sweep through the entire buffer and extract every line that matches a pattern into register a, removing them from the buffer in the
category:
registers
tags:
#registers
#ex-commands
#search
#editing
#global
How do I run a macro until it can no longer proceed without specifying an exact count?
When you give a large count to a macro — such as 100@a — Vim automatically stops replaying the macro as soon as any step inside it fails.
category:
macros
tags:
#macros
#normal-mode
How do I embed per-file Vim settings directly in a source file using modelines?
Vim's modeline feature lets you embed editor settings directly into a file.
category:
config
tags:
#config
#formatting
#indentation
How do I search for text only within a visual selection?
The \%V atom restricts a search pattern to only match inside the most recent visual selection.
category:
search
tags:
#search
#visual-mode
#regex
#substitution
#advanced
How do I schedule a callback to run after a delay in Neovim using the built-in libuv timer API?
Neovim exposes vim.
category:
plugins
tags:
#config
#editing
How do the numbered delete registers work and why does deleted text rotate through registers 1 through 9?
Vim maintains a rotating history of deleted text across registers "1 through "9.
category:
registers
tags:
#registers
#editing
#normal-mode
How do I prevent a macro from stopping when a command fails?
Use :s/pat/rep/e flag or :silent! prefix
By default, Vim macros abort on the first error — a failed search, a substitute with no matches, or a movement that can't be performed.
category:
macros
tags:
#macros
#error-handling
#ex-commands
#batch-editing
How do I configure Vim's command-line tab completion to show all matches and complete to the longest common prefix?
:set wildmode=list:longest
Vim's wildmode option controls how the command line behaves when you press to complete filenames, buffer names, or Ex commands.
category:
config
tags:
#config
#command-line
#completion
#ex-commands
How do I jump between folds in Vim without opening them?
How it works When working with folded code in Vim, you often want to skip from one fold to another without unfolding anything.
category:
navigation
tags:
#navigation
#folding
#normal-mode
How do I briefly highlight text after yanking it to get visual confirmation of what was copied?
The TextYankPost event fires immediately after any yank operation completes — including y, Y, dd, dw, and any other command that writes to a register.
category:
config
tags:
#config
#autocommands
#registers
#visual-mode
How do I configure Vim's built-in file explorer netrw to look like a sidebar?
let g:netrw_liststyle=3 and let g:netrw_banner=0
How it works Vim ships with a built-in file explorer called netrw that you can access with :Explore (or :Ex).
category:
config
tags:
#navigation
#buffers
#windows
How do I run a macro on every line in a visual selection?
The :'normal @a command executes the macro stored in register a on every line within the current visual selection.
category:
macros
tags:
#macros
#visual-mode
#ex-commands
#editing
How do I jump to a mark without adding my current position to the jumplist?
Vim's standard mark-jump commands ('a, ` a `) always add the current position to the jumplist before leaping to the mark.
category:
navigation
tags:
#navigation
#marks
#normal-mode
How do I prevent cursor movement in insert mode from splitting the undo block?
inoremap <Left> <C-g>U<Left>
In insert mode, any cursor movement — including arrow keys, Home, and End — causes Vim to split the undo block at that point.
category:
editing
tags:
#insert-mode
#undo-redo
#editing
How do I paste the contents of a register literally in command-line mode without interpreting special characters?
In command-line mode, {reg} inserts a register's contents — but it processes certain sequences, potentially misinterpreting backslashes, pipe characters, or e
category:
registers
tags:
#registers
#command-line
#search
#editing
How do I move the current line up or down without cutting and pasting?
The :m (move) command relocates lines to a new position in the file without using registers.
category:
editing
tags:
#editing
#ex-commands
#lines
#productivity
#mappings
How do I paste the current filename into the buffer?
The % register in Vim always contains the name of the current file.
category:
registers
tags:
#registers
#editing
#insert-mode
#productivity
#filename
How do I use capture groups to rearrange text in a Vim substitute command?
:%s/\(pattern1\)\(pattern2\)/\2\1/g
Vim's substitute command supports capture groups that let you match parts of text, remember them, and rearrange or reuse them in the replacement.
category:
search
tags:
#search
#substitution
#regex
#ex-commands
#editing
How do I configure Vim's command-line completion to first expand to the longest match, then show a list?
set wildmode=longest:list,full
Setting wildmode=longest:list,full gives Vim a completion behavior similar to shells like bash and zsh.
category:
config
tags:
#command-line
#completion
#config
#wildmenu
How do I use a counter variable inside a Vim macro?
:let i=1 then use <C-r>=i<CR> in macro
By combining a Vimscript variable with the expression register inside a macro, you can create a counter that increments on each replay.
category:
macros
tags:
#macros
#vimscript
#counter
#expression
#advanced