How do I run a macro only on lines that match a specific pattern?
The :g (global) command combined with :normal @a lets you execute a recorded macro only on lines matching a pattern.
category:
macros
tags:
#macros
#ex-commands
#global-command
#editing
#automation
How do I use a macro to wrap each word in quotes?
How it works This macro wraps the current word in double quotes and moves to the next word, making it easy to repeat across a line or file.
category:
macros
tags:
#macros
#editing
#normal-mode
#insert-mode
How do I programmatically load text or a macro into a named register from the command line?
:let @{register}=".
category:
registers
tags:
#registers
#macros
#command-line
#vimscript
How do I edit and reuse previous Ex commands in a full editing buffer?
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
category:
command-line
tags:
#command-line
#ex-commands
#history
#editing
#productivity
How do I preview a tag definition in a preview window using :ptag?
The :ptag command opens a tag definition in a small preview window at the top of the screen, letting you read the definition without losing your place in the cu
category:
buffers-windows
tags:
#buffers
#windows
#tags
#preview
#navigation
How do I refer to the current filename, extension, or directory in Vim ex commands?
Vim's filename modifiers let you derive path components from the current file's name directly inside ex commands.
category:
command-line
tags:
#command-line
#ex-commands
#buffers
How do I pipe selected text through an external command and replace it?
The ! operator in normal mode pipes text through an external shell command and replaces it with the output.
category:
command-line
tags:
#command-line
#shell
#editing
#filtering
#unix
How do I reopen the current file and force Vim to interpret it with a specific line ending format?
The ++ff modifier forces Vim to re-read the current file from disk using a specific fileformat — unix (LF), dos (CRLF), or mac (CR).
category:
editing
tags:
#ex-commands
#editing
#buffers
How do I make gf find files even when the import path omits the file extension?
:set suffixesadd+=.js,.ts,.py
In many programming languages, import statements reference modules without file extensions (e.
category:
navigation
tags:
#navigation
#config
#editing
How do I run a command without triggering any autocommands, such as saving without auto-formatting?
The :noautocmd (abbreviated :noa) prefix suppresses all autocommand events for the duration of the command that follows it.
category:
command-line
tags:
#ex-commands
#config
#editing
How do I match a pattern only when it is preceded or followed by another pattern, without including that context in the match?
Vim's regex engine supports zero-width lookahead and lookbehind assertions using the \@ family of atoms.
category:
search
tags:
#search
#editing
#normal-mode
How do I stop Vim from auto-equalizing split sizes when opening or closing windows?
When you work with carefully sized splits, Vim's default behavior can feel disruptive: opening or closing a window triggers an automatic rebalance.
category:
buffers-windows
tags:
#windows
#buffers
#config
#workflow
How do I prevent Vim from automatically resizing a window when others open or close?
Setting winfixwidth on a window tells Vim not to adjust its width when other windows are created, closed, or resized with =.
category:
buffers-windows
tags:
#buffers-windows
#config
#editing
#windows
How do I make gf find files when import paths omit the file extension?
:set suffixesadd+=.js,.ts,.jsx,.tsx
The gf (go to file) command opens the file under the cursor, but it fails when the path lacks an extension — common in JavaScript/TypeScript imports like impo
category:
navigation
tags:
#navigation
#config
#editing
#buffers
#file-management
How do I always maximize the current split window when I switch focus without using plugins?
:set winwidth=999 winheight=999
Setting winwidth=999 and winheight=999 tells Vim to try to make the active window at least 999 columns wide and 999 rows tall whenever it gains focus.
category:
buffers-windows
tags:
#windows
#config
#buffers
How do I open a diff between my current buffer and the last saved version of the file?
:DiffOrig opens a side-by-side split comparing your current (unsaved) buffer against the version on disk.
category:
buffers-windows
tags:
#diff
#buffers
#editing
#workflow
#buffers-windows
How do I change which characters Vim treats as part of a word for motions and text objects?
iskeyword defines which characters are considered word characters in Vim.
category:
config
tags:
#config
#editing
#search
How do I open a file in a read-only split window in Vim?
The :sview command opens a file in a horizontal split window with the buffer set to read-only.
category:
buffers-windows
tags:
#buffers-windows
#windows
#navigation
#ex-commands
How do I write a search pattern that requires two conditions to match at the same position in Vim?
Vim's \& operator is the AND combinator in a search pattern.
category:
search
tags:
#search
#regex
#ex-commands
#normal-mode
How do I edit a binary file in hex mode using Vim?
Vim can serve as a hex editor by piping buffer contents through xxd, a hex dump utility that ships with Vim.
category:
editing
tags:
#editing
#binary
#ex-commands
#filters