What is the difference between 0 and ^ for moving to the beginning of a line?
Vim has two distinct motions for moving to the start of a line: 0 goes to column 1 (the absolute start), while ^ goes to the first non-blank character.
category:
navigation
tags:
#navigation
#motions
#line-navigation
#indentation
How do I create an incrementing number sequence across multiple lines?
Selecting a column of identical numbers with visual block mode and pressing g turns them into an incrementing sequence.
category:
visual-mode
tags:
#visual-mode
#editing
How do I reverse the order of all lines in a file using Vim?
This clever use of the :global command reverses every line in the current buffer.
category:
command-line
tags:
#editing
#ex-commands
#global
#text-manipulation
How do I search for text I just yanked using the register?
How it works After yanking text, you can use it directly as a search pattern by inserting the yank register contents into the search prompt.
category:
registers
tags:
#registers
#search
#normal-mode
How do I record a macro that processes one line and moves to the next?
How it works When recording a macro that you plan to repeat across multiple lines, the key technique is to end the macro positioned on the next line, ready for
category:
macros
tags:
#macros
#normal-mode
#editing
How do I schedule a command to run after a delay in Vim?
:call timer_start(1000, {-> execute('echo "done"')})
Vim's timerstart() function lets you schedule code to run after a specified delay in milliseconds.
category:
command-line
tags:
#command-line
#timer
#async
#scripting
How do you use a macro to delete the first word of every line?
Record a macro that goes to the start of line with 0, deletes the first word with dw, and moves down with j.
category:
macros
tags:
#macros
#delete
#first-word
How do I make my macros robust regardless of cursor position?
A common macro pitfall is assuming the cursor starts at a specific column.
category:
macros
tags:
#macros
#recording
#best-practices
#workflow
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 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 run Normal mode commands in a script without triggering my custom mappings?
:normal {keys} executes keystrokes as if typed in Normal mode — but it respects your custom mappings and abbreviations.
category:
macros
tags:
#macros
#ex-commands
#normal-mode
How do I create incrementing number sequences in Vim?
The g command increments numbers across a visual selection so that each subsequent line gets a progressively higher value.
category:
visual-mode
tags:
#visual-mode
#editing
#normal-mode
How do I use a macro to align text on a specific character like the equals sign?
qa0f=20i <Esc>20|C= <Esc>lDjq
How it works Aligning text on a delimiter such as = without plugins requires a clever macro technique.
category:
macros
tags:
#macros
#editing
#formatting
#normal-mode
How do I navigate by sentences, paragraphs, and sections in Vim?
Vim provides structural navigation motions that move by sentences, paragraphs, and sections.
category:
navigation
tags:
#navigation
#motions
#sentence
#paragraph
How do I match a pattern only if it is followed by another pattern?
The \ze atom marks the end of the match, so you can match a pattern only when it appears before specific text.
category:
search
tags:
#search
#normal-mode
How do I use a macro to generate a numbered list automatically?
By recording a macro that duplicates a line and increments its number, you can generate a numbered list of any length with a single replay command.
category:
macros
tags:
#macros
#editing
#normal-mode
#automation
#productivity
What is the difference between backtick and apostrophe when jumping to marks?
Vim has two ways to jump to marks: backtick (` `) jumps to the exact line AND column, while apostrophe (') jumps to the line only, positioning the cursor at the
category:
navigation
tags:
#navigation
#marks
#positioning
#motions
How do I search and replace only whole word matches, not partial matches?
Wrapping your search pattern in \ word boundary anchors ensures that Vim only matches the exact whole word, preventing accidental replacements inside longer wor
category:
search
tags:
#search
#substitution
#regex
#ex-commands
#editing
How do I insert register contents into the command line?
How it works While typing an Ex command on the command line (after pressing :), you can insert the contents of any register by pressing Ctrl-R followed by the r
category:
registers
tags:
#registers
#ex-commands
#editing
What is the difference between ' and ` when jumping to a mark in Vim?
Vim provides two distinct ways to jump to a mark, and they behave differently: the apostrophe ' jumps to the first non-blank character of the marked line, while
category:
navigation
tags:
#marks
#navigation
#normal-mode