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

Trying to toogle between 2 versions of statusline.

Initial setting is ok and shows:

marks.local   <%= seperator works>                 2022-09-23 22:45 861 B

Calling :togglestatus results in

marks.local --> /home/user/.config/vifm 6s

Any hints how to toogle 2 versions of statusline and why it seems to break at %= and/or %s

let &statusline = '%f %[--> %T%]%=%d %-6s'
command! togglestatus :if &statusline == '%f %[--> %T%]%=%d %-6s'
      \|    let &statusline = ''
      \| else
      \|    let &statusline = '%f %[--> %T%]%=%d %-6s'
      \| endif

1 Answer

0 votes
by

You must double % in right-hand side of :command due to macro expansion:

let &statusline = '%f %[--> %T%]%=%d %-6s'
command! togglestatus :if &statusline == '%%f %%[--> %%T%%]%%=%%d %%-6s'
      \|    let &statusline = ''
      \| else
      \|    let &statusline = '%%f %%[--> %%T%%]%%=%%d %%-6s'
      \| endif
by

Thanks. Works perfect. Added your answer to my personal vifmrc-cheatsheet.

...