How do you delete text without affecting any register?
"_dd
Use the black hole register " before a delete command.
"_dd
Use the black hole register " before a delete command.
<C-r>{reg} in command line
While on the : command line, pressing followed by a register name inserts that register's contents.
"+yy
The "+yy command yanks the current line directly to the system clipboard register, making it available for pasting in other applications.
"# register
The # register contains the name of the alternate file — the previously edited file in the current window.
:let @b = @a
The :let @b = @a command copies the contents of register a into register b.
"adiw
The "adiw command deletes the inner word under the cursor and stores it in register a.
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.
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.
:redir @a | command | redir END
The :redir command redirects Vim's command output to a register, file, or variable.
"+y and "+p
The "+ register is linked to the system clipboard.
:reg a
The :reg a command shows the contents of register a, which reveals the keystrokes stored in the macro.
"/ register
The / register contains the most recent search pattern.
"1p through "9p
Registers 1-9 contain the last 9 deletions or changes that are at least one line long.
:let @a = "Iprefix: \<Esc>"
The :let @a = ".
".
The .
Use :let i=1 with macro
By combining a Vimscript variable with a macro, you can create sequences with incrementing numbers.
":
The : register contains the last Ex command that was executed.
"=2+3<CR>p
The expression register = evaluates a Vimscript expression and stores the result.
:let @a = ""
The :let @{register} = "" command empties a register.
"ap, edit, "add
Since macros are stored in registers, you can paste the register content into the buffer, edit it, and yank it back.