问题 如何在保留光标下的当前列的同时在vim中找到文件的末尾?


通常当我使用可视模式时,我想将选择扩展到整个文件。但是击中VG会将我带到最后一行的第一个角色。我想把它带到我使用该命令之前的最后一行的同一列。有没有一种简单的方法来实现这一目标?我可以使用200000j那个或者什么,但那不是太优雅。 谢谢。


4256
2018-05-19 04:29


起源

当你使用 V 对于 面向行 视觉模式,无论如何,列都无关紧要,因为选择了整条线。它与...不同 v 和 <C-v>但是。 - Ingo Karkat
是的,我需要这个 C-v。 - egdmitry


答案:


如果你添加 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.

13
2018-05-19 04:37