4

I'm trying to set up a plugin to enable indentation guides, following an answer to this question. The plugin is Yggdroot/indentLine. It has instructions to set up a custom glyph to be shown instead of the default one.

They are:

  1. Download and install FontForge.
  2. Locate and open your terminal/gVim font.
  3. Open the font in FontForge, choose Goto from the View menu and select Private Use Area from the drop down box.
  4. In the private use area, locate a blank spot for the glyph. Make a note of the code, e.g. U+E0A3.
  5. Double-click the selected code point to open the font drawing tool.
  6. From the File menu, select Import... and locate the indentLine-dotted-guide.eps file.
  7. Once imported, choose File -> Generate Fonts and choose a location and file type for the new font.

Once completed, your new font will contain the more subtle dotted guide and all you have to do is set that glyph to g:indentLine_char in your .vimrc file.

I decided to check first if I could to substitute any glyph at all. And I could, I changed the glyph for the A character to a square and set it as the value of the indentLine_char variable. I got this:

enter image description here

But when I tried to define the glyph for a Unicode character from "the Private Use Area", namely U+DE90, I could not insert it into my vimrc file.

Copy/paste does not work from FontForge, so directly insert the char into vimrc is impossible, while it was possible to do this with other chars which were not defined by me, like "┆" etc.

So I wonder, may be there is some way to write Unicode characters by their numeric value in a vim script? E.g. let foo = \U+12323 ?

I have tried instructions from vim.wikia.com, but reproduction a described approach

By hex value for any Unicode codepoint: ^VUnnnnnnnn (with 00000000 <= nnnnnnnn <= 7FFFFFFF)

(the keystrokes in order: Ctrl+V; Shift+U; d; e; 9; 0;) gave me a value in the angle brackets let g:indentLine_char = <de90> and an error:

Error detected while processing ~/.vimrc:
line   16:
E15: Invalid expression: <de90>
E15: Invalid expression: <de90>
Press ENTER or type command to continue

When I tried to enclose it inside brackets, I got another error:

Error detected while processing function <SNR>20_Setup..<SNR>20_IndentLinesEnable:
line   21:
E844: invalid cchar value
E475: Invalid argument: IndentLine /\%(^\s\+\)\@<=\%3v / containedin=ALL conceal cchar=<de90>

Could anyone suggest something about this, please?

4

You are close. You need to use this form:

:let foobar="\u1234"

Using "\u" allows to use up to 4 hex digits. Until recently, it was not possible to use more, but with newer Vims you can now use "\U" plus up to 8 hex numbers.

The details are explained at :h expr-quote

4

Pressing <C-v>ude90 in insert mode should work.

The problem is probably:

let g:indentLine_char = <de90>

which is missing quotes; it should be:

let g:indentLine_char = "<de90>"

(where <de90> is entered with <C-v>, and not 6 separate characters).

See :help i_CTRL-V and :help i_CTRL-V_digit.

  • Thank you, this works as the first answer's approach does, but the problem in some plugin logic. It does not accept such values at all, instead in some bug threads on Github the only advice I could find was to copy a glyph via Ctrl-c/Ctrl-v. So now I'm going to change an existing similar glyph instead of assigning one to an unused code point. – user907860 Jan 19 '16 at 18:41
  • @user907860 Copying a character or inserting it with <C-v> has the same result. – Martin Tournoij Jan 19 '16 at 19:02
  • thank you for noting that, now I found the cause. I tried to add the new glyph to a wrong code point. It should be U+E000 – user907860 Jan 19 '16 at 19:12
1

I tried to figure this out and it turned out that using the below syntax works well for me.

Use "\UE000" not "U+E000"

Note: after importing and generating the font, restart your terminal and Vim. Just so you know use the font that you are using for your terminal.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.