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