代码之家  ›  专栏  ›  技术社区  ›  Thomas

如何在VIM脚本中使用Unicode字符?

  •  2
  • Thomas  · 技术社区  · 16 年前

    我想让Vim把我的标签显示为 ⇥ 所以它们不能被误认为是实际的字符。我希望以下几点能奏效:

    if has("multi_byte")
        set lcs=tab:⇥ 
    else
        set lcs=tab:>-
    endif
    

    然而,这给了我

    E474: Invalid argument: lcs=tab:⇥
    

    文件是UTF-8编码的,包括一个BOM。

    googling“vim encoding”或类似的方法给了我许多关于编辑文件编码的结果,但是没有关于执行脚本的编码。如何将这个字符放入my.vimrc以便正确显示?

    2 回复  |  直到 16 年前
        1
  •  8
  •   Randy Morris    16 年前

    选项卡设置需要两个字符。从 :help listchars :

      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.
    

    类似的东西 :set lcs=tab:⇥- 有效,但有点破坏你的目标,因为它会导致标签看起来像 ⇥--- 而不是 ---⇥ 我想这可能是你想要的。

        2
  •  2
  •   c24w FDinoff    8 年前

    尝试:

    set lcs=tab:⇥\ 
    

    一定要在'\'后面放一个空格,这样你就可以逃离这个空格。