summaryrefslogtreecommitdiffstats
path: root/vim/plugin/nopaste.vim
blob: cb904f70e228566f18fd5097ec68120d732eb7ce (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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>