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

标签 vim

通常当我使用视觉模式时,我想将选择扩展到整个文件。但是点击 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/

相关文章:

vim - 如何在Vim标签文件中找到有问题的格式错误

vim - 如何在 Vim 中不进入插入模式的情况下在光标所在位置插入换行符?

vim - 如何在 Vim 中将表情符号输入到字符串中?

git - 将 git commit 消息的主题行限制为 50 个字符

vim - GVim 作为 TFS 的合并工具

perl - Vim 插件无法识别现有的 Perl 支持

linux - 无法通过 vim 编辑器使用 cscope 多击键

python - 如何将 Django 模块添加到 pydiction 字典?

c++,omnicppcomplete 不显示字符串的方法

c++ - C 和 C++(也可能是 Objective-C)中的 Lint 工具