Created
November 21, 2016 23:03
-
-
Save nilium/3e362d75975ede5ea3ee76b7d1538e33 to your computer and use it in GitHub Desktop.
Stamp-over-word mapping / command
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" Stamp | |
" Maps S (shift+s) to replace the current word under the cursor with whatever's | |
" in the given (or default) register. | |
function! s:Stamp(reg) | |
if a:reg == "" | |
let a:reg = v:register | |
endif | |
execute "let l:v = @" . a:reg | |
exec "norm! viw\"" . a:reg . "p" | |
execute "let @" . a:reg . " = l:v" | |
endfunction | |
command! -register -nargs=? Stamp call s:Stamp("<register>") | |
nnoremap S :execute ":Stamp ".v:register<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment