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.

vifmrc: Syntax of comparison in conditionals

0 votes
asked Aug 2, 2016 in vifm by tagwint

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


What is the right way to check current option value?

1 Answer

0 votes
answered Aug 2, 2016 by tagwint

An ampersand in front of option name was it!

:if &timefmt == "somevalue" 

Could not find that fact mentioned in doc/man though

commented Aug 2, 2016 by xaizek

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

When asking, English language is preferred, but Russian, Ukrainian and maybe German can be used as well (in the last case answers might be in bad German).

If you would like to make a bug report or feature request consider using GitHub, SourceForge or e-mail. Posting such things here won't be considered as a spam, but this is not a perfect place for it.