How do you record a macro to remove comment lines starting with #?
qa/^#\nddq
Record a macro that finds lines starting with # and deletes them.
2277 results for "@a"
qa/^#\nddq
Record a macro that finds lines starting with # and deletes them.
qama{edits}'aq
How it works When a macro needs to jump to different parts of the file and then return to a starting position, marks are the perfect tool.
<C-w>]
The ] command opens the definition of the tag under the cursor in a new horizontal split.
<C-w>H and <C-w>K
After opening a split you can dynamically reposition windows using H, J, K, and L.
buffers-windows #windows #buffers-windows #navigation #normal-mode
:g/pattern/put ='text'
Combining :global with :put = lets you insert synthesized lines of content after every line matching a pattern — without plugins or complex macros.
:call setreg('q', 'dd')
The setreg() VimScript function lets you populate any register with arbitrary content directly from the command line or a script — no recording required.
:%s/,/,\r/g
In Vim substitutions, \n and \r behave differently depending on whether they appear in the search pattern or the replacement string — a common gotcha that sur
:put ={expr}
The :put ={expr} command evaluates a Vimscript expression and inserts the result as a new line below the cursor.
mA to set, 'A to jump
Uppercase marks (A–Z) are global marks — they persist across files and Vim sessions.
:bufdo normal @a
The :bufdo command executes an Ex command in every open buffer, and when combined with :normal @a, it replays macro a across all of them.
macros #macros #buffers #ex-commands #automation #productivity
:match {group} /pattern/
:match, :2match, and :3match give you three independent highlight slots that overlay patterns on the buffer using any highlight group — without touching the s
:m {line-number}
The :m (move) command moves the current line to after the specified line number.
:%norm! A;
The :norm! (or :normal!) command executes normal mode keystrokes while ignoring all user-defined mappings.
:earlier 10m
The :earlier command restores the buffer to its state at a specific time in the past.
u after macro (single undo)
When a macro makes multiple changes, a single u undoes the entire macro as one unit.
nnoremap <key> :<C-u>call MyFunc(v:count)<CR>
When writing custom mappings that call Vimscript functions, a common pitfall is that any count you type before the key (e.
<C-f> from : prompt
Pressing while on the : command line opens the command-line window, where you can edit your command using full Vim editing capabilities.
:sbuffer {N}
:sbuffer {N} opens buffer number N in a new horizontal split, leaving your current window untouched.
buffers-windows #buffers-windows #buffers #windows #navigation
qa:s/\s\+$//e\n jq
Record a macro that runs a substitution on the current line to remove trailing spaces, then moves down.
:set nrformats+=alpha
By default, and only increment and decrement numbers (decimal, hex, and octal depending on format).