diff options
author | Josh Rahm <rahm@google.com> | 2022-09-12 13:50:50 -0600 |
---|---|---|
committer | Josh Rahm <rahm@google.com> | 2022-09-12 13:50:50 -0600 |
commit | 956a805eb9b6e337285349b4de495272ffce5069 (patch) | |
tree | 71a0caefa6c25bb1e2a728d8f3db2c88200d372d | |
parent | b758ef5504a2ae4f147a5f650993133122d840a7 (diff) | |
download | fieldmarshal.vim-956a805eb9b6e337285349b4de495272ffce5069.tar.gz fieldmarshal.vim-956a805eb9b6e337285349b4de495272ffce5069.tar.bz2 fieldmarshal.vim-956a805eb9b6e337285349b4de495272ffce5069.zip |
put.vim: add some more put operations
cpp put over the line
cP put from the current position to the end of the line
["r]{visual}P Paste, but place the yanked text into the provided register.
-rw-r--r-- | plugin/put.vim | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/plugin/put.vim b/plugin/put.vim index 62a0013..2240454 100644 --- a/plugin/put.vim +++ b/plugin/put.vim @@ -2,13 +2,32 @@ " " This is invoked with the 'cp' command. For example " -" cpiw - replace the inner word with the contents of the default register +" cpiw - replace the inner word with the contents of the default regist " "ncpiw - replace the inner word with the contents of register 'n' " +" The cp command also has some standard variants +" +" cpp - replace the whole line with the contents of the default register +" cP - replace from the current cursor position to th end of the line with +" the given register +" " Notably, this command does not alter the contents of the default register, so " this command may be repeated without worry for changing the editor state. noremap <silent> cp <cmd>call <sid>setcpreg(v:register)<bar>set operatorfunc=<sid>put<cr>g@ +noremap <silent> cpp <cmd>call <sid>setcpreg(v:register)<bar>set operatorfunc=<sid>put<cr>g@_ +noremap <silent> cP <cmd>call <sid>setcpreg(v:register)<bar>set operatorfunc=<sid>put<cr>g@$ + +" Like 'p', but in visual mode doesn't clobber the "-register. If invoked with a +" register, the replaced text is put in the given register. +vnoremap <silent> P <cmd>call <sid>paste_into_register(v:register)<cr> + +function! s:paste_into_register(r) abort + let save = getreg('"') + normal! p + call setreg(a:r, getreg('"')) + call setreg('"', save) +endfunction let s:savereg = '' let s:cpbuf = '"' |