From c055c2f90c7ed43ea61775f08d890a5de34a242e Mon Sep 17 00:00:00 2001 From: Josh Rahm Date: Mon, 12 Sep 2022 15:00:50 -0600 Subject: put.vim,charadd.vim: add ability to change bindings --- plugin/put.vim | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'plugin/put.vim') diff --git a/plugin/put.vim b/plugin/put.vim index 2240454..7133fd6 100644 --- a/plugin/put.vim +++ b/plugin/put.vim @@ -14,9 +14,19 @@ " 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 cp call setcpreg(v:register)set operatorfunc=putg@ -noremap cpp call setcpreg(v:register)set operatorfunc=putg@_ -noremap cP call setcpreg(v:register)set operatorfunc=putg@$ +if !exists('g:put_include_bindings') + let g:put_include_bindings = 1 +endif + +noremap (copy-put) call setcpreg(v:register)set operatorfunc=putg@ +noremap (copy-put-line) call setcpreg(v:register)set operatorfunc=putg@_ +noremap (copy-put-end) call setcpreg(v:register)set operatorfunc=putg@$ + +if g:put_include_bindings + noremap cp (copy-put) + noremap cpp (copy-put-line) + noremap cP (copy-put-end) +endif " 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. @@ -49,7 +59,8 @@ function! s:put(arg, ...) abort endif let save = getreg('"') + let savetyp = getregtype('"') silent! exec printf("norm %s\"%sp", vis, s:cpbuf) - call setreg('"', save) + call setreg('"', save, savetyp) endfunction -- cgit