How do I turn a visual selection of lines into a numbered list?
:s/^/\=line('.') - line("'<") + 1 . '. '/
When you need to quickly number a set of lines — such as TODO items, steps, or bullet points — you can use a visual selection combined with a substitution e
category:
visual-mode
tags:
#visual-mode
#editing
#ex-commands
#formatting
#substitute
How do I convert a recorded macro into a permanent key mapping?
:let @q then use in nnoremap
Macros are stored in registers as plain keystroke strings.
category:
macros
tags:
#macros
#config
#vimrc
#mappings
#workflow
How do I delete a word and its surrounding whitespace?
The daw command deletes a word including one side of its surrounding whitespace.
category:
editing
tags:
#editing
#text-objects
#delete
#normal-mode
How do I create an incrementing number sequence from identical numbers in Vim?
When you have multiple lines with the same number and want to turn them into a sequence (1, 2, 3.
category:
editing
tags:
#editing
#visual-mode
#normal-mode
How do I re-open a file in Vim with a specific encoding without restarting?
When Vim auto-detects the wrong character encoding — mojibake where é shows as é is a classic symptom — you can reload the current buffer with a specifi
category:
command-line
tags:
#command-line
#buffers
#ex-commands
How do I insert a shell-escaped current file path in a Vim command-line?
When you build shell commands from Vim, file paths with spaces or special characters can break the command unless properly escaped.
category:
command-line
tags:
#command-line
#filename-modifiers
#shell
#expansion
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 search for a pattern that spans multiple lines in Vim?
Vim's regular expressions support multi-line matching through underscore-prefixed atoms.
category:
search
tags:
#search
#regex
#multiline
#patterns
How do I jump to a specific percentage through a file, like the middle or three-quarters of the way?
Prefixing the % command with a count jumps the cursor to that percentage through the file.
category:
navigation
tags:
#navigation
#motions
#large-files
#normal-mode
How do I limit a search pattern to a specific line range without using :global?
Vim regex supports position atoms that can constrain where a match is allowed to occur.
category:
search
tags:
#search
#regex
#patterns
#navigation
How do I make a macro repeat itself until it fails?
A recursive macro calls itself at the end of its recording, causing it to repeat indefinitely until a command inside it fails (like a search hitting the end of
category:
macros
tags:
#macros
#registers
#editing
#automation
How do I prepend a value to the front of a comma-separated Vim option like path or runtimepath?
Vim's :set command supports three operators for modifying list-style options: += appends, -= removes, and ^= prepends.
category:
config
tags:
#config
#ex-commands
#navigation
How do I define or modify a macro directly as a string without recording it?
Macros in Vim are stored in registers as plain text.
category:
macros
tags:
#macros
#registers
#ex-commands
#normal-mode
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 Vim regex that matches across multiple lines?
By default, .
category:
search
tags:
#search
#editing
#ex-commands
How do I search for the contents of a register without typing the pattern manually?
Vim's search register (@/) holds the current search pattern — the same one used by n, N, *, and hlsearch highlighting.
category:
registers
tags:
#registers
#search
#normal-mode
#ex-commands
How do I collapse multiple consecutive spaces into a single space throughout a file?
The pattern \s\+ matches one or more whitespace characters (spaces, tabs).
category:
editing
tags:
#editing
#search
#ex-commands
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 configure what types of numbers Vim recognizes when using Ctrl-A and Ctrl-X to increment or decrement?
The nrformats option controls which number formats (increment) and (decrement) recognize.
category:
config
tags:
#config
#editing
#normal-mode
How do I insert the result of a Vimscript expression as a new line?
The :put ={expr} command evaluates a Vimscript expression and inserts the result as a new line below the cursor.
category:
registers
tags:
#registers
#ex-commands
#insert-mode
#normal-mode