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

时间:2013-05-19 04:29:42

标签: vim

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

1 个答案:

答案 0 :(得分:13)

如果您在vimrc中添加set nostartofline,则在可视模式下输入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.