" ingo/view.vim: Functions for saving and restoring the window's view. " " DEPENDENCIES: " " Copyright: (C) 2019 Ingo Karkat " The VIM LICENSE applies to this script; see ':help copyright'. " " Maintainer: Ingo Karkat " The functions here allow you to define internal mappings that, when they " surround the right-hand side of your actual mapping, restore the current view " in the current window. Define the right variant(s) based on the mapping " mode(s), and whether a simple winsaveview() will do, or whether you need " "extra strength" to relocate the current position via a temporary mark (when " there are insertions / deletions above the current position, the recorded " cursor position may be off). " noremap (WinSaveView) ingo#view#Save(0) " inoremap (WinSaveView) ingo#view#Save(0) " noremap (WinSaveViewWithMark) ingo#view#Save(1) " inoremap (WinSaveViewWithMark) ingo#view#Save(1) " Use (WinSaveView) from any mode at the beginning of a mapping to save " the current window's view. This is a |:map-expr| which does not interfere with " any pending or mode. " " At the end of the mapping, use (WinRestView) from normal mode to restore " the view and cursor position. " nnoremap (WinRestView) ingo#view#Restore() " Example: > " nnoremap