How do I append the current line to a register from command line without using yank?
:let @a .= getline('.') . "\n"
Named registers are usually filled with yanks and deletes, but they are also plain variables you can edit with Vimscript.
351 results for "registers"
:let @a .= getline('.') . "\n"
Named registers are usually filled with yanks and deletes, but they are also plain variables you can edit with Vimscript.
Use :let i=1 with macro
By combining a Vimscript variable with a macro, you can create sequences with incrementing numbers.
qA
If you finish recording a macro and realize you forgot a step, you don't need to re-record the whole thing.
macros #macros #registers #normal-mode #editing #productivity
:let @q = "dd"
Macros are just strings stored in named registers.
"_d
The "d command deletes text using the black hole register ("), which discards the deleted content instead of storing it.
yy
The yy command yanks (copies) the entire current line, including the newline character.
:let @q = substitute(@q, '\n$', 'A;<Esc>\n', '')
Rerecording a long macro for one tiny change is slow and error-prone.
:let @a = expand('%:p')
Named registers are not only for yanked text.
registers #registers #command-line #filename-modifiers #editing
:let @a = 'text'
Vim's :let command lets you assign a value directly to any named register without performing a yank or delete operation.
registers #registers #macros #vimscript #ex-commands #normal-mode
:let @q = substitute(@q, 'old', 'new', '')
Vim macros are stored as plain text in named registers, which means you can inspect and modify them directly using :let and :echo.
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.
"+q{keys}q
You can record macros into any register, including the system clipboard (+).
:let @q .= 'j'
Re-recording a long macro just to add one extra keystroke is wasteful and error-prone.
:let @q = substitute(@q, '\n', '', 'g')
A common macro failure mode is accidentally hitting while recording.
getreg()
The getreg({name}) function returns the content of any register as a string.
y/<C-r>"<CR>
To search for the exact text you have selected in visual mode, yank it and paste it into the search prompt.
:let @q .= 'A;<Esc>'
Re-recording a long macro just to add one extra step is slow and error-prone.
<C-a> (in insert mode)
While in insert mode, pressing re-inserts whatever text you typed during your previous insert session.
"*
On X11 Linux systems, there are two independent clipboard-like buffers: the primary selection (") and the clipboard ("+).
:<C-r>"
When typing an Ex command or search pattern, you often need to insert text you've already yanked or deleted.