diff options
Diffstat (limited to 'vim/plugin/nopaste.vim')
-rw-r--r-- | vim/plugin/nopaste.vim | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/vim/plugin/nopaste.vim b/vim/plugin/nopaste.vim new file mode 100644 index 0000000..cb904f7 --- /dev/null +++ b/vim/plugin/nopaste.vim @@ -0,0 +1,19 @@ +function! s:nopaste(visual) + if a:visual + silent normal! gv:!nopaste<CR> + else + let l:pos = getpos('.') + silent normal! :%!nopaste<CR> + endif + silent normal! "+yy + let @* = @+ + silent undo + " can't restore visual selection because that will overwrite "* + if !a:visual + call setpos('.', l:pos) + endif + echo @+ +endfunction + +nnoremap <silent><Leader>p :call <SID>nopaste(0)<CR> +xnoremap <silent><Leader>p :<C-U>call <SID>nopaste(1)<CR> |