How do I center-align a block of selected lines at a specific column width in Vim?
After making a visual selection, typing : automatically inserts ' to scope the command to the selection.
category:
visual-mode
tags:
#visual-mode
#formatting
#ex-commands
#indentation
How do I open a file for reference in a dedicated preview window without disturbing my split layout?
Vim has a built-in preview window — a special window distinct from regular splits.
category:
buffers-windows
tags:
#buffers
#windows
#navigation
#ex-commands
How do I open a file and automatically jump to the first line matching a pattern?
The +{cmd} flag on :edit (and most file-opening commands) runs an Ex command immediately after the file loads.
category:
command-line
tags:
#command-line
#ex-commands
#navigation
#search
#buffers
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 programmatically set a register's content in Vim without yanking?
Vim's :let command lets you assign a value directly to any named register without performing a yank or delete operation.
category:
registers
tags:
#registers
#macros
#vimscript
#ex-commands
#normal-mode
How do I run a recorded macro on every file in my argument list at once?
The :argdo command applies any Ex command to every file in the argument list.
category:
macros
tags:
#macros
#ex-commands
#argdo
#normal-mode
#editing
How do I run a dynamically constructed Ex command or pass special keys to :normal?
:execute evaluates a string as an Ex command, letting you build commands dynamically or embed special key sequences (like or ) as literal characters.
category:
command-line
tags:
#ex-commands
#command-line
#macros
#config
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 insert the output of any Vim Ex command directly into the current buffer?
The :put =execute('{cmd}') idiom inserts the output of any Vim Ex command as text in your buffer.
category:
registers
tags:
#registers
#ex-commands
#command-line
#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 load plugins without a plugin manager using Vim's built-in package system?
Since Vim 8 and Neovim, Vim has a built-in package system that can load plugins directly from the filesystem — no external plugin manager required.
category:
plugins
tags:
#plugins
#config
#ex-commands
How do I open any file in a project by partial name without a fuzzy-finder plugin?
By adding to Vim's path option, you enable recursive directory search — which makes :find with tab completion a lightweight project-wide fuzzy finder, no plug
category:
navigation
tags:
#navigation
#ex-commands
#config
#buffers
How do I insert the output of a shell command directly into my buffer?
:put =system('cmd') lets you insert the output of any shell command as new lines in your buffer without leaving Vim.
category:
command-line
tags:
#ex-commands
#shell
#registers
#editing
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 programmatically set a register's content in Vimscript to pre-load a macro?
:let @{reg} = 'string' directly assigns content to any named register from Vimscript.
category:
registers
tags:
#registers
#macros
#ex-commands
#normal-mode
How do I execute Ctrl-W window commands from the command line or a Vimscript function?
:wincmd {key} executes any {key} window command from the Ex command line or from inside a Vimscript function.
category:
buffers-windows
tags:
#windows
#ex-commands
#buffers-windows
How do I anchor a search or substitution pattern to the current cursor position?
The \%# atom in Vim's regex engine matches the exact position of the cursor — zero-width, between characters.
category:
search
tags:
#search
#normal-mode
#ex-commands
#editing
How do I use a Vim expression to dynamically compute substitution replacement text?
The \= prefix in the replacement field of :s/// tells Vim to evaluate the right-hand side as a Vim script expression and use the result as the replacement text.
category:
search
tags:
#search
#substitution
#ex-commands
How do I make Tab trigger wildmenu completion inside a custom mapping?
By default, pressing in a : mapping inserts a literal tab character rather than triggering wildmenu completion.
category:
config
tags:
#config
#ex-commands
#completion
#command-line
How do I open all listed buffers as separate tabs at once?
:tab ball (short for :tab sball, "split all buffers in tabs") opens every listed buffer in its own tab page in a single command.
category:
buffers-windows
tags:
#buffers-windows
#tabs
#ex-commands