Question: I'd like to modify my `.vimrc` to read the value of a variable from an external file. How can I do this?

Specifically, a friend and I share a git repo with our `.vim` files, but there are a few small differences in what we want in our configs. So most of the file is common, but we use if statements to determine whether to load user-specific sections, like this:

```
let whoami = "user2"
if whoami == "user1"
...

```

After checking our common `.vimrc` out of source control, we each have to change the `let whoami` assignment so our own section will be loaded. Instead, I'd like to keep a separate file, which can be different for each of us, and from which vim will load that variable value.

Maybe another angle on this is: **Will vim automatically read all the files in my `.vim` directory?** If so, we could each put a symlink in there called username.vim, and link that to an external file that would be different for each of us.

Answer: 
in your main .vimrc file:

```
source otherVimScriptFilePath.vim

```

then just put your variable statement in that file:

```
" otherVimScriptFilePath.vim
let whoami = "user1"

```
You can have your ~/.vimrc load another file using the `:source` command. For example, you could each put your unique commands in ~/.myvimrc and load those commands with

```
source ~/.myvimrc

```

Or, as you were thinking, you could each put your name in that file like this:

```
let user = "user1"

```

and then put this in your ~/.vimrc:

```
source ~/.myvimrc
if user == "user1"
    " do this
elseif user == "user2"
    " do that
else
    echo "Invalid user"
endif

```

Rather than put your names in files, though, you could use $USER as akira suggested, or set `user` using `whoami`, like this:

```
let user = substitute(system('whoami'), '\n', '', '')

```

The substitute() function is needed because the output of system() usually has a '\n' tacked on the end.