Variables in vimrc
It's tricky to use variables in your virmc.
For example, the following does not work:
" ~/.vim on Unix and ~/vimfiles on Windows
set spellfile = fnamemodify(expand('$MYVIMRC'), ':p:h') . '/spell/en.utf-8.add'
The right hand side does not evaluate in this construction. Vim expects you to set static values to Vim options.
There's a trick with special syntax though. This works:
" ~/.vim on Unix and ~/vimfiles on Windows
let VIMHOME=fnamemodify(expand('$MYVIMRC'), ':p:h')
" Add to the first spellfile (English) with 1zg, the second (Dutch) with 2zg
let &spellfile = VIMHOME . '/spell/en.utf-8.add' . ',' . VIMHOME . '/spell/nl.utf-8.add'
By using the ampersand &, we can indicate that we want to manipulate the option and not a regular variable.
Also notice we now use let instead of set