How do I paste text before the cursor while leaving the cursor positioned after the pasted content?
gP
The gP command works like P (paste before the cursor) but leaves your cursor after the pasted text rather than at its beginning.
351 results for "registers"
gP
The gP command works like P (paste before the cursor) but leaves your cursor after the pasted text rather than at its beginning.
:let @+ = expand('%:p')
Sometimes you need to share or use the full path of the file you're editing — for a terminal command, a config file, or a chat message.
:let @/ = '\V' .. escape(expand('<cword>'), '\\')
Sometimes * is too opinionated: it uses keyword boundaries and interprets regex metacharacters.
:redir @a | messages | redir END<CR>
When debugging a session or building repeatable edits, it is useful to turn command output into editable text.
"add
How it works When you delete text in Vim with commands like dd, dw, or x, the deleted text goes into the unnamed register and the numbered registers (1-9).
"ap, edit, 0"ay$
When a macro has a small mistake, re-recording the entire thing is tedious.
:put =execute('messages')
Vim's :messages command shows recent output — error messages, echo'd values, and diagnostic information — but the display is ephemeral and hard to search.
gr{motion}
Neovim 0.
:call setreg('q', keys, 'c')
The setreg() function writes any string directly into a named register, letting you construct macro keystrokes from Vimscript expressions rather than live recor
:0put
The :put Ex command inserts register contents as a new line below the specified line number.
:let @/ = '\V' . escape(@0, '\')
When the text you yank contains regex characters, a normal / search can produce noisy or surprising matches.
"/
Vim stores the last search pattern in the special / register.
: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 @a = substitute(@a, 'old', 'new', 'g')
After recording a macro or yanking text into a named register, you may need to tweak it — fix a typo in a recorded macro, change a variable name in yanked tex
:keeppatterns %s/old/new/g
The :keeppatterns modifier runs any Ex command without modifying Vim's last search pattern (stored in @/).
command-line #search #ex-commands #command-line #substitute #registers
":p
The : register holds the most recently executed Ex command.
registers #registers #ex-commands #normal-mode #productivity
:keeppatterns normal! @q<CR>
When you replay macros from Ex commands, Vim can overwrite @/ (the last search pattern) depending on what the macro does.
<C-r><C-o>{register}
The standard {reg} pastes register contents in Insert mode, but Vim may auto-indent multi-line text to match the current indentation level — sometimes manglin
<C-r><C-r>x
When you press x in insert mode to paste a register, Vim inserts the text "as if you typed it" — meaning autoindent, textwidth, and other insert behaviors can
"=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.