How can I make .vimrc read from an external file?
Solution 1:
in your main .vimrc file:
source otherVimScriptFilePath.vim
then just put your variable statement in that file:
" otherVimScriptFilePath.vim
let whoami = "user1"
Solution 2:
Using a try/catch
Since asking this question, I've come up with another use case for loading an external file: machine-specific tweaks.
Since I may or may not need to make tweaks on a given machine, I'm using a try/catch
to load the external file; if there's no such file, I let it fail silently.
" If there are any machine-specific tweaks for Vim, load them from the following file.
try
source ~/.vimrc_machine_specific
catch
" No such file? No problem; just ignore it.
endtry