Welcome to Vifm Q&A, where you can ask questions about using Vifm. Registration is optional, anonymous posts are moderated. E-mail and GitHub logins are enabled.
0 votes
in vifm by

I want to toggle between 2 colorschemes named "one" and "two" with a user defined command

I know how to do expressions with settings (:if &quickview...), but have no idea how to use the output of :colorscheme? in an expression.

(Pseudo)code:

:if <active-colorscheme-query-part> == 'one'
    :colorscheme two
:else
    :colorscheme one
:fi

1 Answer

0 votes
by

Current colorscheme is not available as an option or a builtin variable, but you can track which was set last explicitly via an environment variable:

command! cs
      \ :if $COLORSCHEME == 'Default'
      \|     let $COLORSCHEME = 'Default-256'
      \|     colorscheme Default-256
      \| else
      \|     let $COLORSCHEME = 'Default'
      \|     colorscheme Default
      \| endif
by

Thanks. Works almost perfect. When switching colorschemes the first line of colorscheme highlight clear resets/remove also the User1..User20 defined colors for the statusline.

Is there any chance to clear highlights without touching User1..User20? Something like 'highlight clear /^(?!User).*/` (which doesn't work)

by

No, highlight clear pattern is for removing file-name based highlighting like highlight {*.jpg} .... There are also no negative matches in regexps.

Vim handles this by proving ColorScheme auto-command so that switching between color schemes can re-run highlight for User*, but Vifm doesn't have this event.

You can try extracting highlight User* to a separate file and sourcing it from each colorscheme.

by

Thanks again. Putting the highlight User1..20 into a seperate file, which can be sourceed seems the best idea.

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.
...