MacVim from Terminal

I recently found myself setting up a new machine at work. This has resulted in me discovering that a lot of things I had done over the years has been lost to time. Hence the need to document things!

Vim is the best editor ever, and that makes MacVim the best editor in Mac. There are a few ways to get ahold of MacVim. My criteria of success requires that I have MacVim available in my applications folder, and also my terminal.

Homebrew


The most recommended by far on stack overflow. I personally don’t like it, but it’s worth mentioning.

The reason I don’t like it is simple. It’s compiled with different support for python and ruby than what you get if you go grab MacVim from the GitHub releases page. As a result, it doesn’t support the plugins I use.

The biggest benefit to installing through homebrew is that you have mvim available from the terminal right out of the gate. It doesn’t actually put MacVim into the applications folder, so you would assume you could just install through homebrew, and copy the app into /Applications from the github release page, but this actually means you have two copies of the MacVim.app and that means double the updates. Or double the out of date applications.

Github


I’ve mentioned the github page, and even linked to it. here it is again. I will admit to running into some issues. The name of the github page owner isn’t super professional seeming, so the only reason I think I linked to the right page is because if you open a copy of MacVim and go to Help -> MacVim Website and then click on the github page, it takes you to where I linked.

From there, you need to click on releases at the top of the github page, and just download the dmg for whatever release you want.

Back in the day, the dmg contained MacVim.app and mvim a bash script. And there was a readme that said where to copy the bash script. However, it seems there was some arguments about something involving whether the mvim script should open MacVim in a gui, or in the terminal. And then they moved the mvim script inside of the app file. And its nothing like it was the last time I set up a computer.

The new way, – I guess – is to just copy MacVim to applications and then set up an alias in your bash_profile

I don’t know of any obvious pros/cons to the new way vs the old way. Except that I don’t want a bash alias. I want mvim to be inside of my path so that I know it will definitely work as my visual editor no matter what.

Somewhere on stack overflow said to copy the mvim file from MacVim.app into your path, but that didn’t work from me. So I copied my mvim from my old computer and just set it up there.

The old mvim file used to search through its own list of locations to find a MacVim app and then launch it. It has some extra stuff for making sure parameters are passed correctly.

There are a few quirks to this old script. If you have multiple MacVims floating around your machine, you might not get the right one without setting a VIM_APP_DIR environment variable. And I’ve run into times when I wanted macvim to open from a different application without blocking until it finishes running, and other times when I’ve wanted it to block until it finishes running. But all in all, i’ve found it to be a nice ol’ reliable.

Oh, and if you want mvim to launch in the terminal instead of a gui, use the -v flag. weirdly

download the mvim script. rename it to mvim (the .txt extension is just for security so that browsers don’t get upset about downloading executable code) then run the following

and then you should be able to use mvim from terminal

Leave a Comment

Your email address will not be published. Required fields are marked *