lonkey11
lonkey11

Reputation: 49

Installation of MacVim to use gvim

Previously I had gVim running and working; however, my hard drive crashed so everythin'g got erased. Anyways, I am trying to run gVim to open files "-bash: gVim: command not found. I installed X11 and MacVim and did everything that i did before but it just wont open my file. When i open my file with vim it works, but i would prefer gVim.

Any suggestions on how to get givm to work??

Upvotes: 4

Views: 5063

Answers (4)

jonathanzh
jonathanzh

Reputation: 1454

I’m a hard-core gvim user (i.e., I prefer gvim to vi, vim, mvim, and other text editors that are available on Mac). I’ve searched online for “How to install gvim on Mac?”, and have found many answers. The one answer that works best for me is as follows. Assuming you have brew available, on a terminal, type:

brew install macvim

You may be asked to fix some errors. Just follow the onscreen instructions, which may include running commands: brew unlink vim, brew unlink macvim, etc.

Once your macvim has been installed, type the following command:

brew link macvim

If this is successful, then gvim should have been installed, and you can verify this by typing:

which gvim

You should see:

/usr/local/bin/gvim

as the screen output.

Upvotes: 6

cedricdlb
cedricdlb

Reputation: 759

TL;DR: gvim is aliased from the MacVim application's bin folder and you can add that bin directory to your $PATH variable to enable access to gvim from the terminal.

I recently downloaded the latest MacVim.dmg file from https://github.com/macvim-dev/macvim/releases, opened it, in the window that pops up, dragged the MacVim icon to the Applications icon, then closed that window and ejected the MacVim.dmg installer from the finder.

From a finder window I navigated to the /Applications folder, I right-clicked on MacVim.app and selected "Show Package Contents". Then I opened Contents/bin and there found a set of symlinks from mvim and gvim to vim.

I opened a terminal, and changed directory to the home directory by typing cd ~ . From the home directory, I typed ls -al to list all files even the hidden ones which start with a dot, and verify there was a .bash_profile file. (If you don't have this file, see if you have any other other profile files, or search the web to determine which to use or add, so that you can set the following additions to your $PATH variable and have them persist after you log out and back in.)

From the home directory, I used my favorite editor to edit the .bash_profile file, and added the following line to add MacVim's bin file to the $PATH variable: export PATH=$PATH:/Applications/MacVim.app/Contents/bin

I saved and exited the .bash_profile file, then loaded my change with source .bash_profile. Now when I type in the terminal which gvim it lists that location, and I can run gvim from the terminal to open a file.

Upvotes: 1

clt60
clt60

Reputation: 63972

You can install MacVim either from this site:

with macvim you will get the mvim terminal command, what is an small shell script.

Upvotes: 1

romainl
romainl

Reputation: 196809

I'm not sure you know what you are doing.

MacVim has nothing to do with X11 at all so… are you trying to run GVim — the GTK front end of Vim — under X11 (to mimic a Linux desktop, maybe) or do you simply want to run some GUI Vim (GVim or MacVim, whatever).

If you really want GVim, you can install it (and its dependencies) from source but, judging by your question I don't think you should take that path.

If you only want a GUI Vim, the MacVim download comes with a mvim script that you can put anywhere in your $PATH. $ mvim filename will work just like $ gvim filename on Linux.

You can even rename that script to gvim if you absolutely need a gvim command.

Upvotes: 1

Related Questions