How do I evaluate a Vimscript expression and insert the result into a command-line command?
<C-r>= (command-line mode)
Just like = lets you insert evaluated expressions in insert mode, you can use it inside an Ex command on the command line to embed any Vimscript expression resu
category:
command-line
tags:
#registers
#ex-commands
#command-line
How do I search and replace with confirmation for each match?
Adding the c flag to a substitute command makes Vim pause at every match and ask you whether to replace it.
category:
search
tags:
#search
#substitution
#ex-commands
#editing
How do I exclude compiled files and dependency folders from Vim's file name completion?
:set wildignore+=*.pyc,*.o,node_modules/**,.git/**
wildignore is a comma-separated list of glob patterns that Vim skips when expanding file names.
category:
config
tags:
#config
#ex-commands
#completion
How do I make half-page scrolling move through wrapped lines instead of jumping over them in Neovim?
By default, Neovim's half-page scroll commands (, , , ) count movement by text lines, not screen rows.
category:
config
tags:
#config
#navigation
#scrolling
How do I configure Vim's command-line tab completion to show a list of matches?
:set wildmode=longest,list
By default, Vim's command-line completion just cycles through matches one at a time.
category:
config
tags:
#config
#ex-commands
#completion
#command-line
How do I configure command-line tab completion to show the longest match first then cycle?
:set wildmode=longest:full,full
The wildmode option controls what happens when you press in the command line.
category:
config
tags:
#command-line
#completion
#config
How do I run a command across all open buffers at once?
:bufdo %s/old/new/ge | update
The :bufdo command executes an Ex command in every loaded buffer.
category:
buffers-windows
tags:
#buffers
#ex-commands
#editing
#substitution
How do I restrict a Vim search to match only within a specific range of line numbers?
Vim's \%>{lnum}l and \%5l — matches only at positions after line 5 (i.
category:
search
tags:
#search
#regex
#navigation
#ex-commands
How do I trigger wildcard filename completion from inside a custom key mapping in Vim?
The wildchar option (default ) triggers wildcard completion interactively on the command line.
category:
config
tags:
#config
#macros
#command-line
#completion
How do I edit a macro without re-recording it?
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
category:
macros
tags:
#macros
#registers
#editing
#normal-mode
How do I define autocmds safely so they don't duplicate when my vimrc is re-sourced?
Wrapping autocmds in a named augroup with autocmd! at the start prevents duplicate autocommands from accumulating every time your vimrc is sourced.
category:
config
tags:
#config
#ex-commands
#editing
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 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 set a Vim option for only the current buffer or window without affecting others?
:setlocal {option}={value}
:setlocal sets an option only for the current buffer or window, leaving all other buffers and windows unaffected.
category:
config
tags:
#config
#ex-commands
How do I jump to the beginning of the previous word?
The b command moves the cursor backward to the beginning of the previous word.
category:
navigation
tags:
#navigation
#motions
#normal-mode
How do I run normal mode commands in a script or macro without user mappings interfering?
The :normal! command (with !) executes normal mode keystrokes exactly as Vim defines them, ignoring any user-defined mappings.
category:
macros
tags:
#macros
#ex-commands
#normal-mode
#editing
How do I execute a recorded macro a specific number of times?
Prefix the @ macro-execution command with a count to run the macro that many times in a row.
category:
macros
tags:
#macros
#registers
#normal-mode
#editing
How do I integrate a custom build tool or test runner with Vim's :make command and quickfix list?
Vim's :make command runs a build program and automatically loads its output into the quickfix list so you can jump directly to errors and warnings.
category:
config
tags:
#ex-commands
#command-line
#buffers-windows
How do I search or substitute only within specific columns of text in Vim?
The \%Nc, \%>Nc, and \%20c — match only after column 20 (i.
category:
search
tags:
#search
#regex
#substitution
#normal-mode
How do I quickly resize the current window to exactly N lines tall in Vim?
The z{N} command sets the current window's height to exactly N lines and simultaneously positions the current line at the top of the window.
category:
buffers-windows
tags:
#buffers-windows
#windows
#navigation