Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

(mostly) working prototype

  • Loading branch information...
commit 9055c2567fea9b582c343b798158b71531b250b5 1 parent fb29ee7
Marcin Kulik authored

Showing 3 changed files with 37 additions and 0 deletions. Show diff stats Hide diff stats

  1. +1 0  .gitignore
  2. +8 0 doc/pasta.txt
  3. +28 0 plugin/pasta.vim
1  .gitignore
... ... @@ -0,0 +1 @@
  1 +/doc/tags
8 doc/pasta.txt
... ... @@ -0,0 +1,8 @@
  1 +*pasta.txt* Pasting with indentation adjusted to paste destination
  2 +
  3 +Author: Marcin Kulik <http://ku1ik.com/>
  4 +License: Same terms as Vim itself (see |license|)
  5 +
  6 +TODO
  7 +
  8 + vim:tw=78:et:ft=help:norl:
28 plugin/pasta.vim
... ... @@ -0,0 +1,28 @@
  1 +" pasta.vim - Pasting with indentation adjusted to paste destination"
  2 +" Author: Marcin Kulik <http://ku1ik.com/>
  3 +" Version: 0.1
  4 +
  5 +if exists("g:loaded_pasta") || &cp || v:version < 700
  6 + finish
  7 +endif
  8 +let g:loaded_pasta = 1
  9 +
  10 +function! s:normal_pasta(p, o)
  11 + if (getregtype() ==# "V")
  12 + exe "normal! " . a:o . "\<space>\<bs>\<esc>\"" . v:register . "]pk\"_dd"
  13 + else
  14 + exe "normal! \"" . v:register . a:p
  15 + endif
  16 +endfunction
  17 +
  18 +function! s:visual_pasta()
  19 + exe "normal! gv\"_c\<space>\<bs>\<esc>\"" . v:register . "]pk\"_dd"
  20 +endfunction
  21 +
  22 +nnoremap <silent> P :call <SID>normal_pasta('P', 'O')<CR>
  23 +nnoremap <silent> p :call <SID>normal_pasta('p', 'o')<CR>
  24 +
  25 +vnoremap <silent> P :call <SID>visual_pasta()<CR>
  26 +vnoremap <silent> p :call <SID>visual_pasta()<CR>
  27 +
  28 +" vim:set sw=2 sts=2:

0 comments on commit 9055c25

Please sign in to comment.
Something went wrong with that request. Please try again.