0

I use two Macs and use the same ~/.vimrc file, which is stored at Dropbox, and add a symbolic link to it from within both computers at the same location, ~/.vimrc. So I don't think there is any difference whatsoever between the two computer's ~/.vimrc file.

However, when I try to call :tabnew $R from within one computer's MacVim application, the environmental variable is not expanded correctly. The command works on my other computer, and I set $R to ~/r in both of my Macs.

So what does prevent one from being expanded but nonetheless it works on the other? Even echo $R not working on the computer...

The official doc implies that I don't need to set any configuration to properly expand the environmental variable. Also, the environmental variable correctly is expanded in my Terminal.

Is there anything that I'm missing?

Blaszard
  • 30,954
  • 51
  • 153
  • 233
  • 2
    how ecological is an environmental variable? :) – Erik Kaplun Apr 26 '14 at 11:40
  • The question is how environment variables are defined in a GUI application on a Mac. That is explained here: http://stackoverflow.com/questions/603785/environment-variables-in-mac-os-x . I think this counts as a duplicate. – benjifisher Apr 26 '14 at 19:22

2 Answers2

1

If even echo $R is not working, it means the environment variable R simply is not defined on that machine, so there's also nothing to expand in your .vimrc.

Erik Kaplun
  • 37,128
  • 15
  • 99
  • 111
0

I finally got the reason it prevented environment variables from being expanded is that I switched to zsh shell, and it doesn't load those environment variables defined in ~/.zshrc when MacVim is launched. When I used bash shell, I defined all of those variables in ~/.bash_profile.

The solution is to define those variables in ~/.zshenv, not ~/.zshrc. I suspect that the MacVim is assumed to be launched as a shell script, and when a command is executed as a shell script in zsh, only ~/.zshenv is loaded.

Blaszard
  • 30,954
  • 51
  • 153
  • 233