通常当我使用视觉模式时,我想将选择扩展到整个文件。但是点击 VG 会将我带到最后一行的第一个字符。我希望它把我带到最后一行的同一列,就像我在使用该命令之前一样。有没有简单的方法来实现这一目标?我可以使用 200000j 来做那个或其他东西,但这不太优雅。
谢谢。
最佳答案
如果您添加 set nostartofline
到您的 vimrc 输入 G
而在可视模式下将转到底线而不更改列。但是,这可能会更改您使用的其他一些行为,因为它更改了一些其他命令。 (这可能是不可取的)。
帮助 startofline复制在下面,以便您可以查看哪些命令受此设置影响。
*'startofline'* *'sol'* *'nostartofline'* *'nosol'*
'startofline' 'sol' boolean (default on)
global
{not in Vi}
When "on" the commands listed below move the cursor to the first
non-blank of the line. 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.). Also for an Ex command that
only has a line number, e.g., ":25" or ":+".
In case of buffer changing commands the cursor is placed at the column
where it was the last time the buffer was edited.
NOTE: This option is set when 'compatible' is set.
关于vim - 如何在vim中转到文件末尾同时保留光标下的当前列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16631436/