How do I make a macro repeat itself until it fails?
qaq qa...@aq @a
A recursive macro calls itself at the end of its recording, causing it to repeat indefinitely until a command inside it fails (like a search hitting the end of
197 results for "registers"
qaq qa...@aq @a
A recursive macro calls itself at the end of its recording, causing it to repeat indefinitely until a command inside it fails (like a search hitting the end of
:t
The :t command (short for :copy) copies addressed lines to a destination line number, leaving the unnamed register untouched.
qqq qq{commands}@qq @q
A recursive macro calls itself at the end of its recording, causing it to repeat automatically until a motion fails (like j at the last line).
{count}@{register}
Prefix any macro execution with a count to repeat it that many times in a single command.
:let @a=getline('.')<CR>@a
How it works Instead of recording keystrokes interactively, you can write a sequence of Vim commands as plain text in your buffer and then execute that text as
"=expression<CR>p
The expression register ("=) lets you evaluate any Vimscript expression and paste the result directly into your buffer from normal mode.
registers #registers #editing #normal-mode #productivity #math
qqqqqq{edits}@qq
A recursive macro calls itself at the end of its sequence, creating a loop that automatically repeats until a motion or command fails (such as hitting the last
/<C-r>0
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.
:{line}put {register}
How it works The :put Ex command pastes the contents of a register after a specified line.
<C-r><C-r>{register}
In insert mode, {reg} pastes from a register but treats certain bytes as key inputs — so a register containing \n triggers a newline, \x08 triggers backspace,
Write keystrokes in buffer, then "qy$
Instead of recording a macro in real-time (where mistakes mean starting over), you can write the keystrokes as text in a buffer, edit them visually, and then ya
macros #macros #editing #registers #workflow #best-practices
:m+1 / :m-2
The :m (move) command relocates lines to a new position in the file without using registers.
editing #editing #ex-commands #lines #productivity #mappings
"%p
The % register in Vim always contains the name of the current file.
registers #registers #editing #insert-mode #productivity #filename
qaqqa{actions}@aq@a
A recursive macro is a macro that calls itself at the end of its recording.
viwp
The viwp command visually selects the word under the cursor and replaces it with the contents of the unnamed register (your last yank or delete).
visual-mode #editing #visual-mode #registers #paste #productivity
:redir @a | {cmd} | redir END
The :redir command redirects the output of Ex commands to a register, file, or variable instead of displaying it on the screen.
command-line #command-line #ex-commands #registers #productivity #advanced
:g/pattern/yank A
The :g command combined with yank A (uppercase A to append) lets you collect every line matching a pattern into a single register without overwriting previous c
command-line #editing #ex-commands #global-command #registers #filtering