【问题标题】:How to move screen left/right or center it horizontally without moving cursor in vim?如何在vim中不移动光标的情况下左右移动屏幕或水平居中?
【发布时间】:2019-07-27 23:09:43
【问题描述】:

在例如之后在线粘贴我的窗口显示文档的最右侧部分(列> 80)。

将光标留在当前位置时,如何将屏幕水平居中。或者,我可以将屏幕向左移动半个屏幕宽度,避免固定数字,例如44zh?

虽然标题不具体,但所有答案仅涉及向上/向下移动: How to move screen without moving cursor in Vim?

【问题讨论】:

    标签: vim


    【解决方案1】:

    我不知道将屏幕水平居中在光标周围,但就将屏幕向左/向右移动半个屏幕,试试这个(来自:help scroll-horizontal

    zL          Move the view on the text half a screenwidth to the
                right, thus scroll the text half a screenwidth to the
                left.  This only works when 'wrap' is off.  {not in
                Vi}
    
    
    zH          Move the view on the text half a screenwidth to the
                left, thus scroll the text half a screenwidth to the
                right.  This only works when 'wrap' is off.  {not in
                Vi}
    

    【讨论】:

      【解决方案2】:

      你也可以使用:

      zlzh 只移动一个字符

      【讨论】:

        【解决方案3】:

        我使用的一个不错的配置选项是sidescrolloff,它与scrolloff相反。

        我目前在我的 .vimrc 中都使用它们,这是我不能没有的设置。当然,您可以根据需要增加/减少偏移量。我猜这有点取决于您正在处理的文档类型:)

        set scrolloff=20       " keep 20 lines visible above and below cursor at all times                                                                        
        set sidescrolloff=30   " keep 30 columns visible left and right of the cursor at all times
        

        下面是来自 Vim 的一些信息 :help

        scrolloff 保持光标上方和下方的最小屏幕行数。 这将使您工作的地方周围的一些上下文可见。

        sidescrolloff 保持在左侧和右侧的最小屏幕列数 如果设置了“nowrap”,则位于光标右侧。

        【讨论】:

          猜你喜欢
          • 2011-03-28
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-10-25
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多