【问题标题】:Vim: TABs of different widths in visual modes and insert mode?Vim:视觉模式和插入模式下不同宽度的 TAB?
【发布时间】:2013-05-13 21:35:31
【问题描述】:

这个东西像下面这样工作,但如果set tabstop=55,它不起作用:插入模式中的TAB和视觉块模式下的TAB是完全不同的TAB。

  1. 可视块模式(或可视模式)
  2. 选择列的一部分并
  3. 然后按 >

我正在缩进一个大的列文件 - 在这里和那里插入 TAB 和其他微不足道的更改 - 我需要能够在没有不同 TAB 宽度的情况下正确查看内容。

如何让 TAB 在不同模式下成为具有相同宽度的相同 TAB?

【问题讨论】:

    标签: vim indentation


    【解决方案1】:

    您还需要将 shiftwidth 设置为 55。

    来自 vim help

                                                    'shiftwidth' 'sw'
    'shiftwidth' 'sw'       number  (default 8)
                            local to buffer
            Number of spaces to use for each step of (auto)indent.  Used for
            'cindent', >>, <<, etc.
    

    所以在你的 vimrc 中添加

    set shiftwidth=55
    

    【讨论】:

    • +1 应该是原因。也可以将 shiftwidth 设置为 0,以便 sw 使用 ts 值。我们可以只改变一个选项。
    • @Kent 看起来不正确:E487: Argument must be positive: shiftwidth=0。如果只有一个修改而不是两个修改,那就太酷了:'set tabstop=55;设置 shiftwidth=55`。
    • @hhh here (vim 7.3) 我可以设置 sw=0。另外,如果您阅读sw的帮助信息,则有一句话:When zero the 'ts' value will be used.
    • @Kent VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Aug 16 2012 15:12:57,相同版本但无法正常工作,set sw=0set shiftwidth=0 均无效。根据我的 Vim 的错误,它必须是正值。
    • @hhh 我认为它是在补丁 >600 中引入的(我很难找到确切的数字)。你的 vim 最新的补丁是什么。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-06
    • 1970-01-01
    • 2012-02-03
    • 2017-03-14
    • 2019-08-06
    相关资源
    最近更新 更多