How do I debug a macro by executing it step by step?
Paste with "ap and execute keys manually
To debug a macro, paste its contents into the buffer, read each keystroke, and execute them one at a time to find where the macro goes wrong.
Search Vim Tricks
Searching...Paste with "ap and execute keys manually
To debug a macro, paste its contents into the buffer, read each keystroke, and execute them one at a time to find where the macro goes wrong.
qaI"<Esc>A": "",<Esc>jq
This macro transforms a plain word into a JSON key-value pair format, useful for converting lists of field names into JSON structure.
qaciw"<C-r>""<Esc>wq
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.
qaA;<Esc>jq
This macro appends a semicolon to the current line and moves down, ready to repeat.
qaI// <Esc>jq
This macro adds a // comment prefix to the beginning of the current line and moves down.
qa I1. <Esc>j q
This simple macro inserts a list number prefix at the beginning of each line.
<C-v>u{code} in insert mode
In insert mode, u followed by a 4-digit hex code inserts the Unicode character at that code point.
]p
The ]p command pastes text and adjusts its indentation to match the current line.
ciw + new text + Esc, then n.
The ciw command followed by new text, combined with and .
ci`
The ` ci ` command changes the text inside backtick delimiters.
:set updatetime=250
The updatetime option controls how long Vim waits after you stop typing before triggering certain events (like swap file writes and CursorHold autocommands).
V select then :norm A text
Selecting lines and running :norm A text appends the same text to the end of every selected line.
:set termguicolors
The termguicolors option enables 24-bit RGB color support, allowing color schemes to use millions of colors instead of the terminal's 256-color palette.
<C-r>=system('cmd')
In command-line mode, =system('command') evaluates the shell command and inserts its output into the command line.
:s/pattern/replace/flags
The substitute command supports several flags that modify its behavior.
:set belloff=all
The belloff=all option disables all error bells and visual bells in Vim.
:bwipeout
The :bwipeout command (:bw) completely removes a buffer from Vim's memory, including its marks, options, and variables.
<C-w>H
The H command moves the current window to the far left, making it a full-height vertical split.
:enew
The :enew command creates a new unnamed empty buffer in the current window.
<C-w>p
The p command jumps to the previously active window (the last window you were in).