aboutsummaryrefslogtreecommitdiff
path: root/autoload/keep_position.vim
blob: 7ff02287d992e80f3da2ca90decc9ba03be921f0 (plain) (blame)
1
2
3
4
5
6
7
function! keep_position#(command, range, start, end) abort
  let view = winsaveview()
  execute a:command
  if !a:range || (a:start >= line("'[") && a:end <= line("']"))
    call winrestview(view)
  endif
endfunction