How do I restrict keyword completion to current buffer, windows, buffers, and tags for predictable results?
Default keyword completion can feel noisy in large projects because Vim may scan extra sources you do not care about in the moment.
category:
config
tags:
#config
#completion
#insert-mode
#performance
#tags
How do I search for the word under the cursor as a substring, not a whole word?
The and # commands search for the exact whole word under the cursor (with word boundaries \).
category:
search
tags:
#search
#navigation
#normal-mode
How do I sort lines and remove duplicates in Vim?
The :sort u command sorts all lines in the file and removes duplicate lines in one operation.
category:
command-line
tags:
#command-line
#ex-commands
#editing
#text-manipulation
#sort
How do I copy or transfer text between Vim registers?
Vim's :let @{reg} syntax lets you read from one register and write to another.
category:
registers
tags:
#registers
#ex-commands
#editing
#command-line
How do I search for a pattern only within a visual selection?
The \%V pattern atom restricts a search to the region spanned by the last visual selection.
category:
search
tags:
#search
#visual-mode
#patterns
#normal-mode
How do I clear search highlighting in Vim?
The :noh (short for :nohlsearch) command clears the highlighting from the last search pattern.
category:
search
tags:
#search
#ex-commands
#config
How do I navigate between errors and results in the quickfix list?
The quickfix list is Vim's built-in way to collect a list of positions — typically compiler errors, grep results, or linter warnings — and jump between them
category:
buffers-windows
tags:
#buffers
#ex-commands
#navigation
How do I convert space-indented code to tab-indented code in Vim?
:set noexpandtab | retab!
When you inherit space-indented code and need to switch to tabs, :retab! (with the bang) converts groups of spaces into tabs throughout the file.
category:
editing
tags:
#indentation
#editing
#ex-commands
#formatting
How do I paste register contents at the beginning of a file without moving the cursor there first?
The :put Ex command inserts register contents as a new line below the specified line number.
category:
editing
tags:
#editing
#ex-commands
#registers
#normal-mode
How do I reuse the last search pattern without retyping it in Vim?
In Vim, pressing // (two forward slashes) in Normal mode repeats the last search pattern.
category:
search
tags:
#search
#normal-mode
#motions
How do I modify the contents of a register without re-recording it?
:let @a = substitute(@a, 'old', 'new', 'g')
After recording a macro or yanking text into a named register, you may need to tweak it — fix a typo in a recorded macro, change a variable name in yanked tex
category:
registers
tags:
#registers
#macros
#ex-commands
#editing
How do I convert a file from Windows CRLF to Unix LF line endings in Vim?
When you open a Windows file in Vim on a Unix system, you may see ^M at the end of every line — that's the carriage return (\r) from CRLF line endings.
category:
editing
tags:
#editing
#config
#ex-commands
How do I search only the message part of TODO comments using match boundaries?
/\vTODO:\s*\zs.{-}\ze\s*($|#)
When TODO comments include prefixes, owners, or trailing metadata, a plain search often lands on the wrong part of the line.
category:
search
tags:
#search
#regex
#patterns
#comments
How do I run an Ex command without changing the current search pattern?
Many Ex commands silently overwrite the search register (@/), which changes your hlsearch highlighting and n/N behavior.
category:
command-line
tags:
#ex-commands
#search
#command-line
How do I programmatically set the contents of a register from the command line?
The :let @{reg} = expr command lets you assign any string or expression directly into a named register without entering insert mode or performing a yank.
category:
registers
tags:
#registers
#ex-commands
#macros
#normal-mode
How do I run a macro on only the lines I've visually selected?
When you visually select lines and then type a : command, Vim automatically inserts ' (the visual range marks) into the command line.
category:
macros
tags:
#macros
#normal-mode
#ex-commands
#visual-mode
How do I view all available branches in Vim's undo tree to recover changes that u and Ctrl-R can't reach?
Vim's undo history is a tree, not a linear stack.
category:
editing
tags:
#undo-redo
#editing
#command-line
How do I search for a second pattern relative to where the first one matched?
Vim's search offsets allow chaining two patterns together with a semicolon.
category:
search
tags:
#search
#navigation
#normal-mode
How do I limit a search or substitution to only the text I visually selected?
The \%V atom in a Vim pattern matches only inside the last visual selection.
category:
search
tags:
#search
#visual-mode
#substitute
#regex
#text-objects
How do I programmatically manipulate register contents using setreg and getreg?
:call setreg('a', @a . 'text', 'l')
How it works Vim provides two functions for advanced register manipulation: setreg() and getreg().
category:
registers
tags:
#registers
#ex-commands
#editing