set statusline doesn't accept OR expression

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

set statusline doesn't accept OR expression

Hausen Schaff
I'm trying this in vimrc. Vim warns me an error.

set statusline+=%{(&bomb=='1'&& &binary=='0' && (&fenc=='utf-8' || &fenc=='utf-2')) ? '[bom]' : ''}


If I change the OR "||" to "&&", then everything is OK. Any advice is appreciated.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: set statusline doesn't accept OR expression

Tony Mechelynck
On Wed, Mar 6, 2019 at 5:05 AM Hausen Schaff <[hidden email]> wrote:
>
> I'm trying this in vimrc. Vim warns me an error.
>
> set statusline+=%{(&bomb=='1'&& &binary=='0' && (&fenc=='utf-8' || &fenc=='utf-2')) ? '[bom]' : ''}
>
>
> If I change the OR "||" to "&&", then everything is OK. Any advice is appreciated.
>
All spaces and vertical bars in the value must be backslash-escaped,
see :help option-backslash

Try
:set stl+=%{(&bomb\ &&\ !&binary\ &&\ ((&fenc\ ==\ ""\ &&\ &enc\ =~?\
'^u')\ \|\|\ &fenc\ =~?\ '^u')?'[bom]':""}

All these escaping backslashes will disappear in the value displayed
by ":set stl?" (without the quotes of course).

Note the use of =~? '^u' to mean "anything beginning with u or U". I
also omit =1 or =0 for a boolean variable, testing respectively for
nonzero or not(nonzero).

Best regards,
Tony.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.