Sarah
Sarah

Reputation: 6696

Why does "\ " sometimes expand to a single whitespace in Vim's 'statusline', sometimes not?

In my 'statusline' I have %{&ff}%{'\ '.&fenc}. The '\ ' does not expand to a space, but if I change it to '\ \ ' it does. What's going on?

Upvotes: 2

Views: 365

Answers (1)

ZyX
ZyX

Reputation: 53644

It is a bug: I reported it to vim-dev and that was the answer from Bram Moolenaar:

ZyX wrote:

The following code will show `||' in a statusline while it is expected to show

`| |': vim -u NONE -c 'set laststatus=2' -c 'let &statusline="%{\"|\"}%{\" |\"}"'

None of the following code have this issue: vim -u NONE -c 'set laststatus=2' -c 'let &statusline="%{\"|\"}%{\" \"}|"' vim -u NONE -c 'set laststatus=2' -c 'let &statusline="|%{\" |\"}"' vim -u NONE -c 'set laststatus=2' -c 'let &statusline="|%{\" \"}|"'

tested on vim-7.3.47 (revision df6b12c84b23).

Bug found by Sarah (http://stackoverflow.com/questions/4067613).

Isn't this just that leading white space from the expression is always trimmeed? No, putting another item before it makes the space appears. Strange.

Upvotes: 2

Related Questions