I'm trying to assign a key toggle to switch between dark or light background. I wrote this function:
function ToggleBG()
let l:bg='set background?'
if l:bg==dark
:set background=light
elseif l:bg==light
:set background=dark
endif
endfunction
nmap <F6> :call ToggleBG()<cr>
It doesn't work, error,
E121: Undefined variable: dark
E15: Invalid expression: l:bg==dark
The logic is, retrieve current bg setting set background?
, put it in a local variable, l:bg; if it's dark switch it to light and vice versa.
Assign the function to F6 key.
Using Vim 8.1 and Neovim. Any ideas how will this work?
let l:bg = 'set background?'
just assigns the string. I would take a look at:help :let-&
and:help eval
in general