【问题标题】:Jump to last line, but stay in the same column [duplicate]跳到最后一行,但留在同一列[重复]
【发布时间】:2013-05-25 09:24:53
【问题描述】:

在 Vim 中,可以使用G 跳转到最后一行(或使用gg 跳转到第一行),但该移动也会跳转到第一个非空格字符。

是否有一个键绑定可以跳转到第一行(或最后一行),但留在同一列?

【问题讨论】:

标签: vim text-cursor


【解决方案1】:

那就是set nostartofline。有了它,ggG 将尽可能保留该列,就像 j 等一样。

来自:h 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.).  [..]

【讨论】:

    【解决方案2】:

    是的,有一个键绑定。但这很不碍事。

    • 1 CTRL+End: 第一行,同一列
    • CTRL+End:最后一行,同一列

    【讨论】:

    • 尽管这不能回答问题——非常有趣!我不记得以前见过这个命令。很好的发现。
    • 这在我的 Vim 中不起作用。不知道是不是因为我的vim设置或者vim 8.0认为是bug,修复了。
    • @doubleDown 能否详细解释一下,例如,1 在做什么?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-07-19
    • 1970-01-01
    • 2017-10-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多