summaryrefslogtreecommitdiffstats
path: root/vim/plugin/nopaste.vim
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2017-10-29 16:01:43 -0400
committerJesse Luehrs <doy@tozt.net>2017-10-29 19:03:53 -0400
commitd9fd53a62b8fe7698400610d81456e5e3d9461ef (patch)
treefb76c6f3a6da79ec38e693ecb10b346afe9557d6 /vim/plugin/nopaste.vim
parentc8b741e677788b77357c47ee1573f9ffd636c368 (diff)
downloadconf-d9fd53a62b8fe7698400610d81456e5e3d9461ef.tar.gz
conf-d9fd53a62b8fe7698400610d81456e5e3d9461ef.zip
pull a bunch of self-contained things out of my vimrc
Diffstat (limited to 'vim/plugin/nopaste.vim')
-rw-r--r--vim/plugin/nopaste.vim19
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>