Reputation: 96594
I would like vim to point to macvim :)
Probably through an alias.
vim is here: whereis vim
/usr/bin/vim
macvim I can't find, e.g.
whereis macvim
returns nothing
Upvotes: 3
Views: 9332
Reputation: 14135
The MacVim distro comes with a script called mvim
that takes exactly the same arguments as vim
. Put mvim
somewhere in your path. Then, just set the alias: alias vim='mvim'
If you want to completely override the system vim, an easy way is to use Homebrew. Just install MacVim with $brew install macvim --override-system-vim
. The --override-system-vim
flag will create mvim
symlinks to vi
, vim
, etc. You may find it a cleaner way to achieve the same goal. Plus, I prefer to use Homebrew as a package manager.
EDIT: Since you say you don't know where MacVim is, you may just want to download the latest tarball for your system and start from scratch. There are three files: the MacVim application, the mvim
script, and a README.
Put MacVim in your Applications folder. Put mvim
somewhere in your path.
Going forward, you should look for mvim
using which
rather than whereis
. E.g. $which mvim #=> /usr/local/bin/mvim
which
returns the pathnames of the files which would be executed in the current environment. whereis
checks the standard binary directories, and may miss files included in your personal path.
Alternately, use Homebrew, as I suggest above and it will manage the location of both files.
Upvotes: 12
Reputation: 3413
After installing mvim, you can find where it is located with typing into terminal:
which mvim
On my system this gave me:
/usr/local/bin/mvim
Then you create an alias in .bash_profile by typing the following in your terminal, and hit enter:
echo alias vim='/usr/local/bin/mvim' >> .bash_profile
Restart your terminal and try typing:
vim .
This should launch mvim and not vim
Upvotes: 1
Reputation: 196886
My answer is kind of the opposite of michaelmichael's and I've made it quite a few times:
MacVim comes with a CLI executable that you can use in place of Mac OS X's default Vim if you add a single alias to your ~/.bashrc
/~/.profile
. No need to compile anything, no need to put MacVim in a special place, no need to overwrite default programs with symlinks
This way, you can stay in CLI-land and enjoy the power of a powerful/recent/fast Vim.
EDIT
MacVim is a native Mac OS X GUI version of Vim. It doesn't come preinstalled with your OS so you have to download it from the Internet or install it through homebrew (see michaelmichael's answer). Once it's installed, MacVim is where you have put it, plain and simple.
Because it's a full fledged GUI app, MacVim can't really be used as a drop-in replacement for the default Vim in the terminal.
`$ MacVim file.txt` will not work. `$ open -a macvim file.txt` will not work either.
You basically have two options: use the mvim
CLI wrapper to open MacVim from the terminal or use an alias to MacVim's bundled CLI executable.
The mvim
wrapper
I think michaelmichael's answer could be a expanded a bit but the most important is said.
EDIT: well scratch that.
The bundled CLI executable
Just add this line (customized to reflect your system) to your ~/.bashrc
or ~/.profile
or whatever file is run by your shell at startup:
alias vim='/path/to/MacVim.app/Contents/MacOS/Vim'
Open a new terminal window, $ vim file.txt
should launch vim in your terminal window, just like the default /usr/bin/vim
but with a lot more bells and whistles.
Upvotes: 9