Permalink
Browse files

(mostly) working prototype

  • Loading branch information...
1 parent fb29ee7 commit 9055c2567fea9b582c343b798158b71531b250b5 @sickill committed Nov 6, 2011
Showing with 37 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +8 −0 doc/pasta.txt
  3. +28 −0 plugin/pasta.vim
View
1 .gitignore
@@ -0,0 +1 @@
+/doc/tags
View
8 doc/pasta.txt
@@ -0,0 +1,8 @@
+*pasta.txt* Pasting with indentation adjusted to paste destination
+
+Author: Marcin Kulik <http://ku1ik.com/>
+License: Same terms as Vim itself (see |license|)
+
+TODO
+
+ vim:tw=78:et:ft=help:norl:
View
28 plugin/pasta.vim
@@ -0,0 +1,28 @@
+" pasta.vim - Pasting with indentation adjusted to paste destination"
+" Author: Marcin Kulik <http://ku1ik.com/>
+" Version: 0.1
+
+if exists("g:loaded_pasta") || &cp || v:version < 700
+ finish
+endif
+let g:loaded_pasta = 1
+
+function! s:normal_pasta(p, o)
+ if (getregtype() ==# "V")
+ exe "normal! " . a:o . "\<space>\<bs>\<esc>\"" . v:register . "]pk\"_dd"
+ else
+ exe "normal! \"" . v:register . a:p
+ endif
+endfunction
+
+function! s:visual_pasta()
+ exe "normal! gv\"_c\<space>\<bs>\<esc>\"" . v:register . "]pk\"_dd"
+endfunction
+
+nnoremap <silent> P :call <SID>normal_pasta('P', 'O')<CR>
+nnoremap <silent> p :call <SID>normal_pasta('p', 'o')<CR>
+
+vnoremap <silent> P :call <SID>visual_pasta()<CR>
+vnoremap <silent> p :call <SID>visual_pasta()<CR>
+
+" vim:set sw=2 sts=2:

0 comments on commit 9055c25

Please sign in to comment.