What you are observing has nothing to do with eval or expressions: echo eval('$HOME/$NERD_TREE_ROOT') leads to -2147483648 in the same way as echo 0/0 , because both variables turn out to be zeros when performing a numerical operation . The $HOME extension is performed by vim due to the -complete=dir definition in :NERDTree . This is quite unexpected and, by the way, is the third type of extension:: :echo expand('$HOME/$NERD_TREE_ROOT') leads to $HOME/$NERD_TREE_ROOT , and :echo expand('$HOME/$HOME') leads to /home/zyx//home/zyx . I see no way to fix this, but you can always do
execute 'autocmd VimEnter * NERDTree '.fnameescape($HOME.'/'.$NERD_TREE_ROOT)
. This is the only case where the extension works as described in the document, because it is the only way when there are any expressions.
source share