How do I force a register to be linewise before I put it in Vim?
:call setreg('a', @a, 'V')
When you paste from a register, Vim uses that register's stored type: characterwise, linewise, or blockwise.
:call setreg('a', @a, 'V')
When you paste from a register, Vim uses that register's stored type: characterwise, linewise, or blockwise.
:let @a .= expand('%:t') . "\n"
Named registers are not just for yanks and deletes.
:put =strtrans(@q)<CR>
Macro failures are often caused by hidden control keys like , , or tabs that are hard to see in raw register output.
:let @q .= 'j.'
When a recorded macro is almost right but missing one repeated step, re-recording from scratch is usually slower and riskier than patching the register directly
yiww"_ciw\<C-r>0\<Esc>
When you are doing repetitive refactors, cw is fast but it overwrites the unnamed register with the replaced text.
:echo getreg('a', 1, 1)
For advanced register debugging and macro tooling, plain getreg('a') is often not enough.
:let @q .= "A;\<Esc>"
If a recorded macro is almost correct but missing a final step, re-recording from scratch is slow and error-prone.
:call setreg('q', getreg('a'), getregtype('a'))
Simple register copies can silently change behavior when register type is lost.
/\V<C-r><C-r>"
When your yanked text includes regex symbols like .
: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.
:@q
Most macro workflows focus on @q, which replays register q as normal-mode keystrokes.
:call setreg('b', getreg('a'), getregtype('a'))
Plain register copies like :let @b = @a move text, but they can lose important metadata about register type.
:let @a = expand('%:p')
Named registers are not only for yanked text.
registers #registers #command-line #filename-modifiers #editing
:call setreg('a', "foo\nbar", 'b')
Most register examples focus on interactive yanks, but setreg() lets you construct registers programmatically, including their type.
:let @a = getreg('0')
When you want to preserve a valuable yank before doing destructive edits, copying register 0 into a named register is safer than re-yanking text.
registers #registers #yanking #editing #command-line #refactoring
:let @/='\V'.escape(@", '\\')
When you yank text that contains regex characters like .
:let @a=@1
When you delete full lines repeatedly, Vim rotates those deletions through numbered registers.
"=system('git rev-parse --short HEAD')->trim()<CR>p
If you frequently write commit references in notes, code comments, or release docs, you can avoid shell context switches and paste the hash straight from Vim.
:let @a .= getline('.') . "\n"
Named registers are usually filled with yanks and deletes, but they are also plain variables you can edit with Vimscript.
:put =getreg('a', 1, 1)
Most register pastes are character-oriented, but advanced edits often need to preserve exact line structure.
registers #registers #ex-commands #scripting #text-processing