How do I apply a macro to every line in a visual selection?
:'<,'>normal @q
The :'normal @q command runs macro q on every line of the visual selection.
2125 results for "i[ a["
:'<,'>normal @q
The :'normal @q command runs macro q on every line of the visual selection.
<C-v>jjjg<C-a>
Selecting a column of identical numbers with visual block mode and pressing g turns them into an incrementing sequence.
qa Yp <C-a> q
By combining a macro with (increment number), you can quickly generate numbered sequences.
u after macro (single undo)
When a macro makes multiple changes, a single u undoes the entire macro as one unit.
<C-a> in insert mode
Pressing while in insert mode inserts the same text that was typed during the previous insert mode session.
:let @+ = @a
If you already have carefully collected text in a named register, re-yanking just to reach the system clipboard is noisy and error-prone.
:'<,'>normal A;
The :normal command executes normal-mode keystrokes on every line in a range.
command-line #command-line #ex-commands #editing #normal-mode #batch-editing
/\<word\>
The \ atoms create word boundaries in a search pattern, matching only complete words and not substrings within larger words.
A
The A command moves the cursor to the end of the current line and enters insert mode.
:set spellfile={path}
By default, when you use zg to add a word to Vim's spell-check dictionary, it is saved in a file in your Vim data directory.
:m {line-number}
The :m (move) command moves the current line to after the specified line number.
:call setreg('q', getreg('a'), getregtype('a'))
Simple register copies can silently change behavior when register type is lost.
{count}<C-a> / {count}<C-x>
While increments and decrements a number by 1, you can prefix either with a count to add or subtract a specific amount.
:s/\d\+/\=submatch(0)+1/g
The \= prefix in a :substitute replacement field tells Vim to evaluate the following as a Vimscript expression rather than treating it as a literal string.
:vnew | setlocal buftype=nofile bufhidden=wipe nobuflisted noswapfile
For quick throwaway notes, command output cleanup, or temporary edits, a normal buffer is noisy: it appears in :ls, can prompt you to save, and may leave swap a
buffers-windows #buffers-windows #buffers #windows #scratch #workflow
<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.
:echo getreg('a', 1, 1)
For advanced register debugging and macro tooling, plain getreg('a') is often not enough.
:echo string(getreg('q'))
Macros can fail for subtle reasons: hidden control keys, extra whitespace, or unexpected register contents.
registers #registers #macros #debugging #automation #command-line
\@<=pattern
The \@<= atom is a positive lookbehind in Vim regex.
:let @a .= expand('%:t') . "\n"
Named registers are not just for yanks and deletes.