MacOS – How to install MacVim

homebrewmacosmacvim

How do I install MacVim on Mountain Lion? I want to get the MacVim application, as well as the new command-line vim.

I see there are several ways to do it (a snapshot from Google Code, via Homebrew), and if I use Homebrew, I see multiple options. What way will work best both for using the native application as well as using vim on the command line?

Best Answer

Here is the procedure I recommend, for those who are comfortable with the command-line and with Homebrew:

Install Homebrew.

Run the following on the command line (in Terminal):

brew install macvim --with-override-system-vim
brew linkapps

Edit your shell startup files to ensure that /usr/local/bin comes first in your $PATH.

If you use vim as $VISUAL or $EDITOR, add `export VISUAL='mvim -f' to your environment (details).

Check that you installed everything correctly by running

brew doctor

Now, you can run the graphical MacVim on a file by running mvim foo.txt from the command-line. Or, you can run the text-based editor by running vim foo.txt. Also, if other programs (e.g., git) fork off a separate editor, they'll run the graphical MacVim.

See also How to run mvim (MacVim) from Terminal? and Set macvim as default application after homebrew installation.