Skip to content

Commit

Permalink
Restore cursor position after undoing \= reformat
Browse files Browse the repository at this point in the history
  • Loading branch information
yangle committed Feb 24, 2020
1 parent 7b5001e commit ce27e17
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions _vimrc
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ noremap L g_
" Command wrapper that preserves the current window view.
function! WithViewPreserved(command)
" Manully insert an undo block that preserves the current cursor position.
" https://github.com/rhysd/vim-clang-format/pull/55
silent execute "noautocmd normal! ii\<esc>\"_x"
let w = winsaveview()
execute a:command
call winrestview(w)
Expand Down

0 comments on commit ce27e17

Please sign in to comment.