3

I have this lines for my statusline

 set statusline=%{&paste?'\ \ paste\ ':''}
 set statusline+=\ %{expand('%:~:.')!=#''?expand('%:~:.'):'[No\ Name]'}
 set statusline+=%{&readonly?'\ \ [RO]':!&modifiable?'\ \ [RO]':''}

I removed other parts for avoiding useless complexity. As you can see, I need to put two spaces before [RO] in the third/last line when I only get one in output. Why is that?

Edit: My version is NVIM v0.3.0-dev

3

Inside a %{} the first space character in the expression seems to be always removed. For example, let &statusline="%{' ]'}" displays the string " ]". It also seems to be independent of fillchars. That is, if set fillchars=stl:^, "^]^^^^" will be displayed. Why this happens or if it's intentional is quite mysterious to me (hopefully someone else can answer this question).

A workaround is to use a different space character, e.g., a non breaking space 0xA0:

let &statusline="%{'\ua0xyz'}"

or

set statusline=%{\"\\ua0xyz\"}
  • Thanks for answering. I don't need a workaround, not really. I just wanted to know what I'm doing wrong. – klaus May 27 '18 at 15:15
  • Understood, let's wait for some other answers. I'm hoping one of the vim-airline maintainers see this, because they probably have the most experience with extreme statusline customization. – Mass May 27 '18 at 15:18

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.