How do I use variables in my .vimrc?

This is working:

let my_sw = 20
let &sw = my_sw

Now you can figure how to fix your code


you can't use variables on the rhs in the .vimrc.

try :help feature-list for more info. for unix vs windows for example (not sure what your projects are):

if has("unix")
    " do stuff for Unix
elseif has("win32")
    " do stuff for Windows
endif

might work, or another example is

execute "set path=".g:desktop_path

If g:desktop_path contains spaces, you will have to escape those, either in the original setting of g:desktop_path or when setting 'path', e.g.,

execute "set path=".escape(g:desktop_path, ' ')

See

:help let-option
:help execute
:help escape()

Tags:

Vim