13

通常,当我使用可视模式时,我想将选择范围扩展到整个文件。但是点击 VG 会将我带到最后一行的第一个字符。我希望它带我到最后一行的同一列,就像我在使用该命令之前一样。有没有简单的方法来实现这一目标?我可以为此使用 200000j 或其他东西,但这不是太优雅。谢谢。

4

1 回答 1

17

如果您在可视模式下添加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.
于 2013-05-19T04:37:31.210 回答