I'm playing around with my .vimrc as usual. I have a colorscheme which displays differently with

let ayucolor="dark"
let ayucolor="mirage"
let ayucolor="light"

I'm thinking about how to dynamically, i.e. via shortcut, to set this ayucolor during my editing of file. I've tried

:let var='value'

which doesn't work.

  • @BLayer: Sorry for vagueness and good points. – job_start Apr 22 at 5:14
  • 1
    For example, this is legal and will assign the string to ayucolor: :nnoremap X :let ayucolor = "dark"<CR> (single quotes will work here, too) – B Layer Apr 22 at 5:27
  • 1
    Looks like XY problem to me. – Maxim Kim Apr 22 at 6:48
  • 3
    I’m voting to close this question because the answer has almost nothing to do with the title or body of the question, and as such it's very unlikely to help future readers. – Rich Apr 22 at 9:56
  • 1
    My sense of betrayal aside ;) ...hard to argue with Rich. I enjoyed attempting to amuse folks with my overinflated, self-congratulatory answer but there's probably not much to benefit others beyond that. :) – B Layer Apr 22 at 22:20

A milestone in my question answering career: this is the first time I solved something with nothing but a pure, unadulterated, grade-A SWAG. I don't know how much value this will have for anyone but the OP but an answer is an answer. Forgive the padding. ;)

I didn't seen anything wrong with the sample code in the question. These are both perfectly valid assignments of a string to a variable:

:let ayucolor="dark"
:let var='value'

Based on the mention of using a shortcut, I thought maybe there was some question about whether this would also work in an indirect context such as a mapping. No problem there; it can be dropped right in like this, for instance...

:nnoremap X :let ayucolor = 'dark'<CR>

Commence assumptions...

  • The idea is to alter some characteristic of a color scheme via a variable (setting).
  • "It doesn't work" probably means "nothing happens" since any errors/warnings that appeared would surely be noted in the question.
  • A color scheme is a pretty static thing so if the setting in question is initialized in the color scheme file itself we're probably out of luck as far as being able to change things live/on-the-fly.
  • There must be a default that gets used only if a value is not specified before the :colo call.



The color scheme will need to be reloaded after you initialize/change the ayucolor variable.


And the crowd goes wild!

  • 1
    Good job, Sherlock – Rich Apr 22 at 9:57
  • 1
    Wild crowd cheering noises – statox Apr 22 at 13:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.