【问题标题】:Is it possible to show tabs as tabs when in list mode?在列表模式下是否可以将选项卡显示为选项卡?
【发布时间】:2024-01-18 09:44:02
【问题描述】:

我试图在 Vim 中将尾随空格显示为句点,但制表符显示为制表符。

这是我正在查看的帮助文档。

'listchars' 'lcs'   string  (default "eol:$")
            global
            {not in Vi}
    Strings to use in 'list' mode and for the |:list| command.  It is a
    comma separated list of string settings.
                            *lcs-tab*
      tab:xy    Two characters to be used to show a tab.  The first
            char is used once.  The second char is repeated to
            fill the space that the tab normally occupies.
            "tab:>-" will show a tab that takes four spaces as
            ">---".  When omitted, a tab is show as ^I.

我的.vimrc 文件中目前有以下两行。

exec "set listchars=tab:>-,trail:\uB7,nbsp:~"
set list

我应该用什么替换字符 >- 以便标签显示为普通标签?

字符序列尝试并失败:

  • 两个空格
  • 两个空格和\ 在每个空格之前转义
  • 制表符和空格

当我执行后者时,我得到一个看起来像这样的错误。

Error detected while processing /home/hq6/.vimrc:
line  202:
E474: Invalid argument: listchars=tab:^I 

【问题讨论】:

    标签: vim


    【解决方案1】:

    :set listchars=tab:\ \ ,eol:$ 为我工作。

    【讨论】:

    • 这似乎不适用于 `exec "set listchars=tab:\ ,trail:\uB7,nbsp:~"`,我认为这是评估 Unicode 字符所必需的。跨度>
    【解决方案2】:

    Paul 的回答提醒我,我打电话给exec,所以我可能需要额外的转义层。我刚刚尝试了以下方法,它可以工作。

    exec "set listchars=tab:\\ \\ ,trail:\uB7,nbsp:~"
    set list
    

    【讨论】:

      最近更新 更多