rid
rid

Reputation: 63542

Vim statusline separation (%=) with Unicode characters

When I set fillchars=stl:x statusline=a%=b, I see the following statusline:

axxxxxb

When I set fillchars=stl:· statusline=a%=b (· = middle dot, U+00B7), the status line becomes:

a-----b

The same happens with Unicode box drawing characters (they become -).

I would have expected:

a·····b

What am I missing or doing wrong?

If I don't set statusline to anything, then the default statusline draws the Unicode character correctly, something like:

~/.vimrc·····1,1·····Top

Upvotes: 2

Views: 720

Answers (2)

rid
rid

Reputation: 63542

Looks like Vim does not currently support multi-byte fill characters in custom status lines (version 8.1.2203):

/* Can't handle a multi-byte fill character yet. */
else if (mb_char2len(fillchar) > 1)
    fillchar = '-';

To work around the issue, I created a function that draws the line instead:

function StatusLine()
    let left = 'a'
    let right = 'b'

    let spacer_width = winwidth(0) - len(left) - len(right)
    let spacer = repeat('·', spacer_width)

    return left . spacer . right
endfunction

set statusline=%{StatusLine()}

Upvotes: 2

Matt
Matt

Reputation: 15186

This is currently not supported.

Quote from :h 'fcs':

for "stl" and "stlnc" only single-byte values are supported.

Upvotes: 1

Related Questions