1

I can do the following to set the synmtaxcol:

:set synmaxcol=4

Or:

:let &synmaxcol=4

However, when doing the same with colorscheme, only this works:

colorscheme TextMate

And not:

let &colorscheme="TextMate"

Or:

let g:colors_name="TextMate" 

When is the let syntax available to use / how would I update the colors with a let statement?

1

Short answer: let can be used with vimscript variables, registers, environment variables and options. As colorscheme is not one of those (it’s a different mechanism—it involves sourcing a file, which itself must give g:colors_name the appropriate value), it cannot be set this way.

To use options, the & syntax a few variants are helpful. Why? Often we want to save and restore options:

let save_cpo = &cpo
let &cpo = save_cpo

Or we want to set an option more programmatically:

let &path = some_fancy_expression

The latter in particular is easier to read and deal with than :execute "set path=".some_fancy_expression.

2
  • thanks, is it possible to set the colorscheme via running a let command? – David542 Jun 13 '20 at 3:50
  • 1
    Not as far as i know—you can use execute "colorscheme" expression though – D. Ben Knoble Jun 13 '20 at 12:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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