A minimal invasive solution for the lazy ones:
Register 0
always contains the last yank (as Rafael, alex2k8 and idbrii have already mentioned). Unfortunately selecting register 0
all the time can be quite annoying, so it would be nice if p
uses "0
by default. This can be achieved by putting the following lines into your .vimrc
:
noremap p "0p
noremap P "0P
for s:i in ['"','*','+','-','.',':','%','/','=','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
execute 'noremap "'.s:i.'p "'.s:i.'p'
execute 'noremap "'.s:i.'P "'.s:i.'P'
endfor
The first line maps each p
stroke to "0p
. However, this prevents p
from accessing any other registers. Therefore all p
strokes with an explicitly selected register are mapped to the equivalent commandline expression within the for-loop. The same is done for P
.
This way the standard behaviour is preserved, except for the implicit p
and P
strokes, which now use register 0
by default.
Hint 1: The cut command is now "0d
instead of just d
. But since I'm lazy this is way too long for me ;) Therefore I'm using the following mapping:
noremap <LEADER>d "0d
noremap <LEADER>D "0D
The leader key is \
by default, so you can easily cut text by typing \d
or \D
.
Hint 2: The default timeout for multi-key mappings is pretty short. You might want to increase it to have more time when selecting a register. See :help timeoutlen
for details, I'm using:
set timeout timeoutlen=3000 ttimeoutlen=100
viwp
(forw
ord). – OJFord