blob: 05f69bc1f01b459ab67d4b1c4fc5a9c5bbc9b9aa (plain
*keep_position.txt* For Vim version 7.0 Last change: 2019 Jun 3
This tiny plugin provides a command prefix to run commands without moving the
cursor or window view around. It does this by saving the window view before
running the command, and then restoring it afterwards.
This plugin only loads if 'compatible' is not set. It also requires the
Run the given command while preserving the cursor position and window view.
Works rather like |:keepalt| or |:keepjumps|. It's good for filters,
especially ones that work on the entire buffer:
You will generally want to use this command as above, without a range.
However, if you do specify a range, it will only preserve the view if the last
change to the buffer--presumably made by your nominated command--entirely
encompassed the given range. This is checked with the |'[| and |']| marks.
The author uses the range functionality to make a "conditional jump"; only
jump to the changes the given command makes if it didn't affect the entire
:nnoremap u :<C-U>%KeepPosition undo<CR>
Written and maintained by Tom Ryder <email@example.com>.
Licensed for distribution under the same terms as Vim itself (see |license|).