aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2019-05-23 14:14:00 +1200
committerTom Ryder <tom@sanctum.geek.nz>2019-05-23 14:14:00 +1200
commite8833acf27ab6e5df511281465ea0f751398a6b0 (patch)
treed7409493f1e60e77aa9bce7e189efbc512b5d374
parent5274128a3b8f5adbadf000564e00b9c9ab55016b (diff)
downloadvim-squeeze-repeat-blanks-e8833acf27ab6e5df511281465ea0f751398a6b0.tar.gz
vim-squeeze-repeat-blanks-e8833acf27ab6e5df511281465ea0f751398a6b0.zip
Restore cursor position after run
-rw-r--r--autoload/squeeze_repeat_blanks.vim6
1 files changed, 6 insertions, 0 deletions
diff --git a/autoload/squeeze_repeat_blanks.vim b/autoload/squeeze_repeat_blanks.vim
index 1b760b4..9776643 100644
--- a/autoload/squeeze_repeat_blanks.vim
+++ b/autoload/squeeze_repeat_blanks.vim
@@ -2,6 +2,9 @@
" group, deleting the others.
function! squeeze_repeat_blanks#Squeeze(start, end) abort
+ " Save cursor position
+ let pos = getpos('.')
+
" List of line numbers to delete
let deletions = []
@@ -36,6 +39,9 @@ function! squeeze_repeat_blanks#Squeeze(start, end) abort
silent execute num . 'delete'
endfor
+ " Restore cursor position
+ call setpos('.', pos)
+
" Report how many lines were deleted
echomsg len(deletions) . ' deleted'