Browse files

Merge pull request #3 from suy/modification-marks

Save and restore modification marks in NormalPasta
  • Loading branch information...
2 parents ada8a5c + 10c3a13 commit 736e2df09c11a623080e71150576e94fb700e8b8 @sickill committed Apr 4, 2012
Showing with 10 additions and 1 deletion.
  1. +10 −1 plugin/pasta.vim
View
11 plugin/pasta.vim
@@ -9,7 +9,16 @@ let g:loaded_pasta = 1
function! s:NormalPasta(p, o)
if (getregtype() ==# "V")
- exe "normal! " . a:o . "\<space>\<bs>\<esc>" . v:count1 . '"' . v:register . ']pk"_dd'
+ exe "normal! " . a:o . "\<space>\<bs>\<esc>" . v:count1 . '"' . v:register . ']p'
+ " Save the `[ and `] marks (point to the last modification)
+ let first = getpos("'[")
+ let last = getpos("']")
+ normal! k"_dd
+ " Compensate the line we have just deleted
+ let first[1] -= 1
+ let last[1] -= 1
+ call setpos("'[", first)
+ call setpos("']", last)
else
exe "normal! " . v:count1 . '"' . v:register . a:p
endif

0 comments on commit 736e2df

Please sign in to comment.