How do I force a case-insensitive substitution without changing the global ignorecase setting?
:%s/pattern/replacement/ig
The :s substitute command accepts /i and /I flags that override your global ignorecase and smartcase settings for that single substitution, letting you choose c
category:
search
tags:
#search
#editing
#ex-commands
#normal-mode
How do I create a macro that only acts on lines matching a search pattern?
By starting a macro with a search command, the macro becomes conditional — it jumps to the next match before acting, and terminates when no more matches are f
category:
macros
tags:
#macros
#search
#conditional
#pattern
How do I wrap an entire line in surrounding characters using vim-surround?
The yss{char} mapping from the vim-surround plugin surrounds the entire current line (ignoring leading whitespace) with the chosen delimiter.
category:
plugins
tags:
#plugins
#editing
#surround
#text-objects
How do I swap two adjacent words on a line using a substitute command in Vim?
:s/\v(\w+)\s+(\w+)/\2 \1/
By using capture groups in a substitute command with very magic mode (\v), you can swap two adjacent words in a single operation.
category:
search
tags:
#search
#editing
#substitute
#regex
#text-objects
How do I make Ctrl-A and Ctrl-X increment and decrement alphabetical characters in Vim?
By default, Vim's and commands only increment and decrement numbers (decimal, hex, binary).
category:
config
tags:
#config
#editing
#normal-mode
#macros
How do I move by visible screen lines instead of actual lines?
When a long line wraps across multiple screen rows, the regular j and k motions skip the entire logical line.
category:
navigation
tags:
#navigation
#motions
#normal-mode
#text-editing
How do I inspect what key sequences are stored in a macro register?
When a macro behaves unexpectedly, :echo strtrans(@q) reveals exactly what is stored in register q—including invisible control characters—as human-readable
category:
macros
tags:
#macros
#registers
#debugging
How do I override ignorecase or smartcase for a single search without changing my settings?
Vim's \c and \C flags let you force a search to be case-insensitive or case-sensitive on a per-search basis, regardless of your ignorecase and smartcase setting
category:
search
tags:
#search
#normal-mode
#ex-commands
How do I execute a command without changing '[ and '] marks in Vim?
Many batch edits in Vim update special marks like '[ and '], which can disrupt follow-up motions or tooling that depends on those positions.
category:
navigation
tags:
#navigation
#marks
#command-line
#refactoring
#editing
How do I change surrounding quotes or brackets from one type to another with vim-surround?
The vim-surround plugin (by Tim Pope) adds three powerful operators for working with surrounding delimiters — quotes, brackets, parentheses, and HTML tags.
category:
plugins
tags:
#plugins
#text-objects
#editing
How do I search backward for the word under the cursor?
The # command searches backward for the exact word under the cursor, jumping to the previous occurrence.
category:
search
tags:
#search
#navigation
#normal-mode
How do I add text to the end of every line in a range?
The :normal command executes normal-mode keystrokes on every line in a range.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#normal-mode
#batch-editing
How do I run a substitution or command on every line in the quickfix list?
:cdo {cmd} executes {cmd} on each entry in the quickfix list — one by one, jumping to each location in turn.
category:
command-line
tags:
#ex-commands
#quickfix
#search
#editing
#buffers
How do I use a Vimscript expression to compute the replacement text in a substitution?
Prefixing the replacement field of :s with \= makes Vim evaluate the rest as a Vimscript expression and use the result as the replacement string.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line
How do I use capture groups in Vim substitutions to rearrange or swap matched text?
Vim's substitute command supports capture groups using \( and \) (or ( and ) in \v very-magic mode).
category:
search
tags:
#search
#editing
#substitution
#regex
#ex-commands
How do I match text only when it is followed by a specific pattern using zero-width lookahead?
Vim's regex engine supports zero-width positive lookahead via the \@= operator.
category:
search
tags:
#search
#regex
#lookahead
#advanced
#pattern
How do I open a file in Netrw in a vertical split instead of the current window?
When browsing files in Vim's built-in file manager (Netrw), pressing v on any file opens it in a vertical split to the right.
category:
plugins
tags:
#buffers-windows
#navigation
#editing
How do I open a file in Vim without triggering any autocmds for faster loading?
When you have heavy autocmds registered for BufRead, BufEnter, or FileType events — such as LSP clients, formatters, or syntax processors — opening a large
category:
command-line
tags:
#command-line
#ex-commands
#buffers-windows
#config
How do I browse and manage files using Vim's built-in file explorer?
:Explore / :Vexplore / :Sexplore
Vim ships with netrw, a built-in file explorer that lets you browse directories, open files, create new files, rename, and delete — all without plugins.
category:
buffers-windows
tags:
#navigation
#buffers
#file-management
#netrw
#productivity
How do I paste or reuse my last search pattern?
Vim stores your last search pattern in the / register.
category:
registers
tags:
#registers
#search
#insert-mode
#command-line