From e12149d5d620832716770ad4c746e2ac4c2b03a9 Mon Sep 17 00:00:00 2001 From: Tom McDonald Date: Sat, 1 Aug 2015 15:19:51 -0400 Subject: [PATCH] Avoid screen jumps when scrolled to second region --- plugin/exchange.vim | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plugin/exchange.vim b/plugin/exchange.vim index 88f853a..439ac87 100644 --- a/plugin/exchange.vim +++ b/plugin/exchange.vim @@ -16,6 +16,8 @@ function! s:exchange(x, y, reverse, expand) let yindent = matchstr(getline(nextnonblank(a:x.start.line)), '^\s*') endif + let view = winsaveview() + call s:setpos("'[", a:y.start) call s:setpos("']", a:y.end) call setreg('z', a:x.text, a:x.type) @@ -37,6 +39,8 @@ function! s:exchange(x, y, reverse, expand) call s:reindent(a:y.start.line - xlines + ylines, xlines, xindent) endif + call winrestview(view) + if a:reverse call cursor(a:x.start.line, a:x.start.column) else