开发者

How to use Unicode characters in a vim script?

开发者 https://www.devze.com 2022-12-29 16:00 出处:网络
I\'m trying to get vim to display my tabs as ⇥ so they cannot be mistaken for actual characters. I\'d hoped the following would work:

I'm trying to get vim to display my tabs as so they cannot be mistaken for actual characters. I'd hoped the following would work:

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

However, this gives me

E474: Invalid argument: lcs=tab:⇥

The file is UTF-8 encoded and includes a BOM.

Googling "vim encoding" or similar gives me many results about the encoding of edited files, but nothing about the encoding of executed scripts. How to get this character into my .vimrc so that it is properly 开发者_JAVA百科displayed?


The tab setting requires two characters. From :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.

Something like :set lcs=tab:⇥- works but kind of defeats your purpose as it results in tabs that look like ⇥--- instead of ---⇥ which I'm assuming is probably what you wanted.


Try:

set lcs=tab:⇥\ 

Make certain to put a space after the '\' so you can escape the space.

0

精彩评论

暂无评论...
验证码 换一张
取 消