How do I use a Vim expression to dynamically compute the replacement in a substitution?
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
category:
registers
tags:
#search
#editing
#ex-commands
#registers
How do I jump between matching if/else/endif or other language constructs?
The % command jumps between matching brackets by default, but with the built-in matchit plugin, it extends to match language-specific keywords like if/else/endi
category:
navigation
tags:
#navigation
#plugins
#matching
#code-navigation
How do I convert variable names between snake_case, camelCase, and other naming conventions with vim-abolish?
The vim-abolish plugin adds coercion operators that instantly convert the word under the cursor between common naming conventions.
category:
plugins
tags:
#editing
#text-objects
#plugins
#normal-mode
#formatting
How do I center text on the current line using a built-in Vim command?
Vim has three built-in ex commands for text alignment that most users never discover: :ce (center), :ri (right-justify), and :le (left-justify).
category:
editing
tags:
#editing
#formatting
#ex-commands
#text-formatting
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 delete through the end of the next search match from the cursor?
When you need to remove text up to a known marker, a plain search motion is often almost right but stops at the start of the match.
category:
navigation
tags:
#navigation
#search
#motions
#editing
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 start typing at the end of a line in Vim?
The A command moves the cursor to the end of the current line and enters insert mode.
category:
editing
tags:
#editing
#insert-mode
#normal-mode
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 rename a variable across all its case variants (camelCase, snake_case, SCREAMING_CASE) in one command?
vim-abolish provides :Subvert, a smarter substitute that detects and preserves the case style of each match.
category:
plugins
tags:
#editing
#search
#ex-commands
How do I export my syntax-highlighted Vim buffer to an HTML file?
The :TOhtml command converts the current buffer — complete with its syntax highlighting colors — into a standalone HTML file.
category:
command-line
tags:
#ex-commands
#command-line
#editing
How do I jump to a specific column number on the current line?
The command (pipe character) moves the cursor to a specific column number on the current line.
category:
navigation
tags:
#navigation
#motions
#columns
#normal-mode
How do I access and manipulate the last search pattern as a register?
Vim stores the last search pattern in the special / register.
category:
registers
tags:
#registers
#search
#command-line
How do I rotate split windows forward without reopening any buffers?
When a split layout is correct but the window positions are awkward, you do not need to close and reopen anything.
category:
buffers-windows
tags:
#windows
#buffers
#command-line
#navigation
How do I enable Ctrl-A and Ctrl-X to increment and decrement binary numbers like 0b1010 in Vim?
Vim's and commands increment and decrement numbers under the cursor, but by default they only handle decimal and hexadecimal.
category:
config
tags:
#editing
#config
#increment
#normal-mode
#numbers
How do I convert the entire current line to lowercase or uppercase in one command?
Vim's case operators gu (lowercase) and gU (uppercase) follow the same doubling convention as dd and yy: repeating the operator letter applies it to the whole c
category:
editing
tags:
#editing
#normal-mode
How do I look up documentation for the keyword under the cursor?
Pressing K in normal mode runs a lookup program on the word under the cursor.
category:
navigation
tags:
#navigation
#help
#documentation
#normal-mode
#keywordprg
How do I highlight all occurrences of a yanked word without typing a search pattern?
After yanking text, you can promote it directly to the search register with :let @/ = @".
category:
registers
tags:
#registers
#search
#hlsearch
#normal-mode
How do I trigger a code action at the cursor position using Neovim's built-in LSP?
Since Neovim 0.
category:
plugins
tags:
#lsp
#neovim
#code-action
#editing
#plugins
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