How do I programmatically set the contents of a register from the command line?
The :let @{reg} = expr command lets you assign any string or expression directly into a named register without entering insert mode or performing a yank.
category:
registers
tags:
#registers
#ex-commands
#macros
#normal-mode
How do I search for a second pattern relative to where the first one matched?
Vim's search offsets allow chaining two patterns together with a semicolon.
category:
search
tags:
#search
#navigation
#normal-mode
How do I limit a search or substitution to only the text I visually selected?
The \%V atom in a Vim pattern matches only inside the last visual selection.
category:
search
tags:
#search
#visual-mode
#substitute
#regex
#text-objects
How do I programmatically manipulate register contents using setreg and getreg?
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
category:
registers
tags:
#registers
#ex-commands
#editing
How do I define a multi-line string in Vimscript without concatenation or escape sequences?
Vim 8.
category:
command-line
tags:
#ex-commands
#config
#macros
How do I record a self-repeating recursive macro that automatically stops when it hits an error?
A recursive macro is one that calls itself at the end of its own recording.
category:
macros
tags:
#macros
#registers
#normal-mode
How do I enable inline character-level diff highlighting in Neovim's diff mode?
:set diffopt+=linematch:60
Neovim's linematch diffopt enables intra-line diff highlighting — instead of marking an entire changed line, Neovim highlights only the specific characters th
category:
config
tags:
#config
#diff
#buffers-windows
How do I switch to the previous buffer in Vim?
The :bprev (or :bp for short) command switches to the previous buffer in Vim's buffer list.
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
How do I move the cursor to a specific column on the current line?
The command moves the cursor to a specific screen column on the current line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I configure Vim's :grep command to use a faster external search tool like ripgrep or ag?
:set grepprg={cmd} grepformat={fmt}
Vim's :grep command delegates to an external tool defined by grepprg, then parses the output according to grepformat to populate the quickfix list.
category:
search
tags:
#search
#ex-commands
#config
#buffers
How do I search through command history and only see commands that start with what I've already typed?
In Vim's command line, and navigate history in prefix-filtered mode — they only cycle through past commands that begin with whatever you have already typed.
category:
command-line
tags:
#command-line
#history
#navigation
How do I use gn as a text object to delete or yank the next search match?
The gn motion is a versatile text object that selects the next occurrence of the last search pattern.
category:
editing
tags:
#editing
#search
#text-objects
#normal-mode
#motions
How do I copy the contents of one register into another register?
Vim's :let command lets you read and write register contents as strings, making it possible to copy, combine, or modify register values without ever leaving the
category:
registers
tags:
#registers
#ex-commands
#editing
#normal-mode
How do I define a custom Ex command that can accept a line range or count like built-in Vim commands?
:command -range {Name} ...
Custom Ex commands defined with :command -range can be called with a line range (e.
category:
command-line
tags:
#command-line
#ex-commands
#config
How do I use PCRE-style regex in Vim without escaping every special character?
Vim's default regex mode ("magic") requires backslashes before many special characters: \(, \ , \+, \{.
category:
search
tags:
#search
#regex
#patterns
#normal-mode
How do I save the current search pattern into a named register before it gets overwritten by a new search?
Vim stores the last search pattern in the special / register (@/).
category:
registers
tags:
#registers
#search
#ex-commands
How do I jump to any visible text on screen with a two-character search using flash.nvim in Neovim?
flash.
category:
plugins
tags:
#navigation
#motions
#plugins
#search
How do I run a macro a dynamically computed number of times or interleave it with other commands?
:for i in range(1,10) | execute "normal @q" | endfor
Using a Vimscript :for loop with execute "normal @q" lets you run a macro with a dynamically computed iteration count and interleave other Ex commands between i
category:
macros
tags:
#macros
#ex-commands
#normal-mode
How do I navigate compiler errors, grep results, or search matches using the quickfix list?
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
category:
navigation
tags:
#navigation
#quickfix
#ex-commands
#productivity
#workflow
How do I run a macro on every line in a specific line number range?
The :normal command lets you execute Normal mode keystrokes over a range of lines.
category:
macros
tags:
#macros
#normal
#range
#ex-commands