Don't use exists("g:...") then == to lookup globals, use one get(). This is faster.
Don't use exec to set known variables
Setting variables using exec only makes sense if the variable name comes from the value of another variable, not how it was being used. Aside from omitting dangerous behavior (exec =~ eval), it's slightly faster.
Don't set &background as this can cause vim to re-load the color scheme.
According to the documentation, this causes the color scheme to be
loaded TWICE.
When a color scheme is loaded (the "g:colors_name" variable is set)
setting 'background' will cause the color scheme to be reloaded. If
the color scheme adjusts to the value of 'background' this will work.
However, if the color scheme sets 'background' itself the effect may
be undone. First delete the "g:colors_name" variable when needed.
Essentially, color schemes should not set the value of &background.
I tested these changes on vim 8.0.1453 and they appeared to work with no syntax errors, and color scheme loaded correctly.
Don't use
exists("g:...")
then==
to lookup globals, use oneget()
. This is faster.exec
to set known variablesSetting variables using
exec
only makes sense if the variable name comes from the value of another variable, not how it was being used. Aside from omitting dangerous behavior (exec
=~eval
), it's slightly faster.&background
as this can cause vim to re-load the color scheme.According to the documentation, this causes the color scheme to be loaded TWICE.
Essentially, color schemes should not set the value of &background.
I tested these changes on vim 8.0.1453 and they appeared to work with no syntax errors, and color scheme loaded correctly.