How do I make a macro prompt for user input at a specific point during its execution?
<C-r>=input('Enter: ')<CR>
By embedding =input('prompt: ') inside a recorded macro, you can pause the macro at any point to ask for user input and insert the result.
category:
macros
tags:
#macros
#insert-mode
#registers
#editing
How do I completely remove a buffer from Vim?
The :bwipeout command (:bw) completely removes a buffer from Vim's memory, including its marks, options, and variables.
category:
buffers-windows
tags:
#buffers
#ex-commands
How do I visualize and navigate Vim's undo tree?
The undotree plugin provides a visual tree representation of Vim's undo history.
category:
plugins
tags:
#plugins
#undo-redo
How do I join all selected lines into one line?
In visual mode, pressing J joins all selected lines into a single line with spaces between them.
category:
visual-mode
tags:
#visual-mode
#editing
How do I run a macro on all lines matching a pattern?
The :g/pattern/norm @a command combines the global command with macro execution.
category:
macros
tags:
#macros
#ex-commands
#search
How do I jump directly to a specific line number in Vim?
When you know the exact line number you want to navigate to, the colon command is the quickest way to get there.
category:
navigation
tags:
#navigation
#motions
#ex-commands
How do I choose from multiple tag matches when a tag has several definitions?
When a tag has multiple definitions (e.
category:
navigation
tags:
#navigation
#ex-commands
How do I record a macro to toggle comments on a line?
This macro adds a // comment prefix to the beginning of the current line and moves down.
category:
macros
tags:
#macros
#editing
How do I record a macro to add semicolons at the end of every line?
This macro appends a semicolon to the current line and moves down, ready to repeat.
category:
macros
tags:
#macros
#editing
How do I record a macro to wrap each word in quotes?
This macro wraps the current word in double quotes by changing the word, inserting quotes around the original content, and moving to the next word.
category:
macros
tags:
#macros
#editing
#registers
How do I append the same text to the end of several lines?
V select then :norm A text
Selecting lines and running :norm A text appends the same text to the end of every selected line.
category:
editing
tags:
#editing
#ex-commands
How do I put selected text inside quotes or brackets manually?
Without a surround plugin, you can manually wrap selected text by changing it, typing the delimiters, and pasting the original text back.
category:
visual-mode
tags:
#visual-mode
#editing
How do I indent lines multiple times without reselecting in visual mode?
Normally, pressing > in visual mode indents the selection but exits visual mode, requiring you to press gv to reselect.
category:
visual-mode
tags:
#visual-mode
#indentation
#mapping
#editing
How do I edit a command in a full Vim buffer before executing it?
Pressing while on the : command line opens the command-line window, where you can edit your command using full Vim editing capabilities.
category:
command-line
tags:
#command-line
#ex-commands
How do I delete the word before the cursor without leaving insert mode?
Pressing in insert mode deletes the word before the cursor instantly, without requiring you to switch to normal mode.
category:
editing
tags:
#editing
#insert-mode
#delete
#productivity
How do I delete all lines matching a pattern?
The :g/pattern/d command deletes every line in the file that matches the given pattern.
category:
command-line
tags:
#search
#ex-commands
#editing
#command-line
How do I increment or add to all numbers in a file using Vim substitution?
:%s/\d\+/\=submatch(0)+1/g
Vim's expression replacement (\=) in substitutions lets you perform arithmetic on matched text.
category:
search
tags:
#search
#substitute
#arithmetic
#numbers
How do I append text at the end of lines with different lengths using visual block?
When lines have varying lengths, a normal visual block selection stops at the shortest line.
category:
visual-mode
tags:
#visual-mode
#editing
#block-mode
#append
How do I make Vim transparently edit .gz files using built-in tooling?
Compressed logs and artifacts often appear in debugging workflows, and repeatedly shelling out to decompress and recompress wastes time.
category:
plugins
tags:
#plugins
#files
#command-line
#workflow
How do I find which plugin or script defined a specific mapping?
The :verbose prefix on mapping commands shows not just the mapping definition but also the file and line number where it was defined.
category:
command-line
tags:
#command-line
#verbose
#debug
#mapping