Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed MacVim using homebrew. (brew install macvim). If I call mvim from cmd, it opens the GUI MacVim.

I would like to make vim call the MacVim's Vim (/Users/user/Applications/ instead of the system's (/usr/bin/vim) vim. Which is the best way to do it? I know I can do an alias vim="/Users/user/Applications/" but I don't know if it's the best approach...

EDIT: Guys, thank for all your answers, but indeed, since I'm already using homebrew, using the --override-system-vim is the elegant way to accomplish what I need.

share|improve this question
What's the difference between MacVim console vim and just regular vim in Terminal? – hobbes3 Mar 24 '12 at 17:38
@hobbes3, the vim that ships with osx does not have ruby or python support compiled in. MacVim's vim does. Which is necessary if you want to use plugins like Command-T – asgeo1 Mar 31 '12 at 3:10
up vote 107 down vote accepted

I believe this is what you're looking for:

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

This will create vim, vimdiff, etc. symlinks to mvim in /usr/local/bin/vim, and as long as /usr/local/bin is before /usr/bin in your PATH, you'll get the results you're looking for.

Earlier versions of brew used the switch --override-system-vim which was deprecated.

share|improve this answer
Since I said I'm already using homebrew, I think this is indeed the best option: I didn't know this option was possible. Thanks! – Somebody still uses you MS-DOS Sep 11 '11 at 21:31
+1 It's nice finding hidden gems in homebrew. – Adam Lewis Sep 12 '11 at 1:09
Technically, this is a hidden gem in the vim formula, rather than homebrew itself. :) – kejadlen Sep 12 '11 at 18:40
I wonder, what if I do an brew remove macvim, will that remove macvim and leave the original vim? Or that will also be gone? – Ben Mezger Aug 27 '13 at 11:59
This apparently needs the full Xcode installed via the app store (and not just the command line tools). – ScoBe Jun 3 '15 at 11:19

The Vi command line switch works.

alias vim='mvim -v'

share|improve this answer

You can create an alias in your ~/.bash_profile, just add this line to that file:

alias vim="/Users/user/Applications/"
share|improve this answer
Actually, it would be alias vim="/Users/user/Applications/", since I want to link to the MacVim's console vim and not the gui version. – Somebody still uses you MS-DOS Sep 11 '11 at 2:32
Ahh, alright. Fixed! – Wuffers Sep 11 '11 at 2:33
Since vim is an interactive application, doing an alias that overrides the System's Vim isn't going to be that harmful, I guess... – Somebody still uses you MS-DOS Sep 11 '11 at 2:47
For me this was in /Applications. Nice alias! – user72923 Sep 25 '12 at 22:56

To change the system's default editor add the following to your .bash_profile

export EDITOR=/usr/local/Cellar/macvim/<version>/bin/mvim 

Changing this should allow you to use MacVim for the default editor (even for the app that autolaunch the editor)

For normal usage at the terminal, you would still have to use 'mvim' to edit a file. If you still want to type 'vi' on the terminal, I would suggest adding the alias to the .bash_profile as well.

After seeing the OP's edit, you could prepend the the path of MacVim's vim to the system path. Note I do not think this is the best way because it could effect other system calls as well while making calls at the terminal. So if you really just want it to change when you type 'vim' at the command line then the use of an alias I believe to be the cleanest and safest thing to do.

export PATH

Test your settings by using which vim at the terminal.

share|improve this answer
I don't want to make mvim the default. I want to call MacVim's vim (/Users/user/Applications/ when I write down vim on terminal instead of system's vim (/usr/bin/vim). – Somebody still uses you MS-DOS Sep 11 '11 at 2:49
@Somebody still uses you MS-DOS: Sorry about that, mis-understood your intent (makes a bit more since now viewing your edit). – Adam Lewis Sep 11 '11 at 2:53
Hum, but you gave me an idea: if I symlink vim to /usr/local/bin and using the $PATH approach, it may work. – Somebody still uses you MS-DOS Sep 11 '11 at 3:02
@Somebody still uses you MS-DOS: Be careful symlinking to a directory that already has vim in it... It might become difficult to know which vim you're going to get. – Adam Lewis Sep 11 '11 at 3:04
:) My mind jumped to the worst case (local removed). You should be fine with user local. – Adam Lewis Sep 11 '11 at 3:15

I don't want to install xcode just for this, also I don't want to use aliases or brew method (which also requires xcode) so I do this:

  1. I first download MacVim from the releases page,
  2. Then I install MacVim by dragging it to my Applications folder,
  3. For terminal usage, there's also a terminal app in the zip, called mvim, I install it by running this command:

    sudo mv mvim /usr/local/bin/vim

  4. And then, I rehash the environment by hash -r (or close and re-open the terminal).

  5. Finally, when I run vim from my terminal I see the updated one "in the console".

I hope this helps someone.

share|improve this answer
I use homebrew for lots of stuff. It's worth the hassle. Having XCode installed but being able to install all I need just by calling brew install is great. – Somebody still uses you MS-DOS Mar 17 '15 at 6:59

My two cents, I run this whenever upgraded my python via homebrew.

brew reinstall vim --HEAD --with-cscope --with-lua --override-system-vim
brew reinstall macvim --HEAD --with-cscope --with-lua --override-system-vim
share|improve this answer

brew install macvim --override-system-vim is deprecated. You should use brew install macvim --with-override-system-vim instead.

share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .