Welcome to Vifm Q&A, where you can ask questions about Vifm usage. Registration is optional, anonymous posts are moderated. GitHub or Google logins are enabled.
0 votes
in vifm by

I cannot figure out the right syntax for comparing string value of an option

all these work:

command uuu  :if 1 == 1 | :set timefmt='%%Y-%%m-%%d' |  :endif
command uuu  :if "1" == "1" | :set timefmt='%%Y-%%m-%%d' |  :endif
command uuu  :if '1' == '1' | :set timefmt='%%Y-%%m-%%d' |  :endif

however when I try to compare current value of timefmt option with either single-or-double quoted string

command uuu  :if timefmt == "somevalue" | :set timefmt='%%Y-%%m-%%d' |  :endif
command uuu  :if timefmt == 'somevalue' | :set timefmt='%%Y-%%m-%%d' |  :endif

my :uuu command fails wtih

:endif without :if

message.

What is the right way to check current option value?

1 Answer

0 votes
by

An ampersand in front of option name was it!

:if &timefmt == "somevalue" 

Could not find that fact mentioned in doc/man though

by

Yes, the same as in Vim. It's documented where expressions are explained (here).

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here is acceptable, but this is not a perfect place for them.
...