Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Unicode characters in a vim script?

Tags:

vim

unicode

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 displayed?

like image 831
Thomas Avatar asked Jul 21 '26 01:07

Thomas


1 Answers

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.

like image 120
Randy Morris Avatar answered Jul 23 '26 13:07

Randy Morris