How do I browse and restore previously deleted text using Vim's numbered registers?
"1p then u. to cycle through delete history
Vim silently maintains a rolling history of your last 9 deletions in numbered registers "1 through "9.
351 results for "registers"
"1p then u. to cycle through delete history
Vim silently maintains a rolling history of your last 9 deletions in numbered registers "1 through "9.
:call setreg('a', @a, 'v') then "ap
Use setreg() to change register a to characterwise mode (v), then paste.
:set shada='200,<1000,s100,h
Default ShaDa settings are conservative, which can make long-running workflows lose useful context between sessions.
"1p and .
When you paste from a numbered register with "1p, Vim's dot command (.
:let @/ = 'pattern'
Use :let @/ = 'pattern' to set the search register directly.
<C-r>%
In insert mode, % inserts the current filename.
5"ap
Prefix the paste command with a count.
<C-r>#
The # register holds the alternate (previously edited) filename.
:@:
The : register stores the last command-line command.
:call setreg('a', 'text')
Use setreg() to set register contents from Vimscript.
"aVaBy
Position cursor in a function, use VaB to visually select the block including braces, then "ay to yank into register a.
"ayip
Use "ayip to yank the inner paragraph into register a.
"ayis
Use "ayis to yank the inner sentence into register a.
:let @a = 'hello world'
Use :let @a = 'text' to set register a to any string.
<C-r>.
In insert mode, .
"aP
Use "aP (uppercase P) to paste the contents of register a before the cursor position, as opposed to "ap which pastes after.
"ap
In visual mode, "ap replaces the selected text with the contents of register a.
:let @a = toupper(@a)
Use Vimscript functions toupper() or tolower() with :let @a = toupper(@a) to convert the case of the entire register contents.
"a]p
Use ]p after specifying a register to paste with adjusted indentation.
/<C-r>a
While in the search prompt (/), press a to insert the contents of register a.