如何在vim页up/down时保持光标的垂直位置?
How to keep the cursor's vertical position when page up/down in vim?
我想在向上翻页 (Ctl-U
) 或向下翻页 (Ctl-D
) 时保持光标的垂直位置。当我在一个长 python 函数中并想通过缩进找出块结构时,这特别有用。
我向下翻页时的当前行为:
if foo:
xxx = yyy
^ <-- cursor was here before page down
... many content in between ...
while bar:
xxx = yyy
^ ^ <-- cursor jumped here after page down
^ <-- I want it to stay here
我想你想看看 'startofline'
/'sol'
选项。
默认为on
,但描述为
When off the cursor is kept in the same column
(if possible). This applies to the commands: CTRL-D, CTRL-U, CTRL-B,
CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>"
with a linewise operator, with "%" with a count and to buffer changing
commands (CTRL-^, :bnext, :bNext, etc.).
我想在向上翻页 (Ctl-U
) 或向下翻页 (Ctl-D
) 时保持光标的垂直位置。当我在一个长 python 函数中并想通过缩进找出块结构时,这特别有用。
我向下翻页时的当前行为:
if foo:
xxx = yyy
^ <-- cursor was here before page down
... many content in between ...
while bar:
xxx = yyy
^ ^ <-- cursor jumped here after page down
^ <-- I want it to stay here
我想你想看看 'startofline'
/'sol'
选项。
默认为on
,但描述为
When off the cursor is kept in the same column (if possible). This applies to the commands: CTRL-D, CTRL-U, CTRL-B, CTRL-F, "G", "H", "M", "L", gg, and to the commands "d", "<<" and ">>" with a linewise operator, with "%" with a count and to buffer changing commands (CTRL-^, :bnext, :bNext, etc.).