aboutsummaryrefslogtreecommitdiff
path: root/doc/keep_position.txt
blob: 05f69bc1f01b459ab67d4b1c4fc5a9c5bbc9b9aa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
*keep_position.txt*	For Vim version 7.0	Last change: 2019 Jun 3

DESCRIPTION				*keep_position*

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.

REQUIREMENTS				*keep_position-requirements*

This plugin only loads if 'compatible' is not set.  It also requires the
|+user_commands| feature.

COMMANDS				*keep_position-commands*

					*:KeepPosition*
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:
>
    :KeepPosition %!tidy
<
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
buffer, e.g.:
>
    :nnoremap u :<C-U>%KeepPosition undo<CR>
<
AUTHOR					*keep_position-author*

Written and maintained by Tom Ryder <tom@sanctum.geek.nz>.

LICENSE					*keep_position-license*

Licensed for distribution under the same terms as Vim itself (see |license|).

 vim:tw=78:ts=8:ft=help:norl: