Skip to content
gglanzani edited this page May 25, 2012 · 23 revisions

How do I save configuration settings?

All settings should be saved in a file named .gvimrc which must be located in your home folder (abbreviated ~/). Note that you have to create this file if one does not already exist. Your home folder is the one called /Users/name where name is your login name. Type :h vimrc-intro for more information on Vim configuration files.

How can I change the default font?

Add the line set guifont=Monaco:h14 to your .gvimrc to set Monaco as the default font with a size of 14.

How can I set the default size of new windows?

Add the line set lines=40 to your .gvimrc to make 40 the default number of rows. To set the default number of columns to 100 add the line set columns=100.

If you want the window as big as possible, you can set these options to very large values or you can type :set lines? and :set columns? after having manually maximized the window to find out how big it is and then add these values to your .gvimrc.

Note that the dimensions of the first window you open are automatically saved and used for every window you open thereafter.

How do I maximize the window horizontally as well as vertically?

Hold down Cmd when clicking the green zoom button. If you want this to be the default behavior, open Terminal and enter

$ defaults write org.vim.MacVim MMZoomBoth 1

How do I configure Xcode to open files in MacVim?

In Xcode, open the Preferences and click the "File Types" tab, then expand "file -> text". Under the "text" item there is an entry called "sourcecode"; click the second column (Preferred Editor) of this entry and choose "External Editor -> Other". Navigate to MacVim in the dialog that pops up.

The "external editor" support in Xcode is very limited. Basically all the above change does is to open source code files in MacVim. You can also double click on build errors to open MacVim on the line where the error was reported.

How can I make the toolbar stay hidden after a restart?

Add the line set guioptions-=T to your .gvimrc file.

How can I prevent Finder file labels from disappearing when saving a file?

Add the line set backupcopy=yes to your .gvimrc file. Type :h 'backupcopy' for more information on why this is necessary.

How can I open files from Terminal?

Put the script mvim which comes bundled with the MacVim download somewhere in your path. Type :h macvim-start for more information.

How can I use MacVim to edit Git commit messages?

Add the following line to the file ~/.profile:

export EDITOR='mvim -f --nomru -c "au VimLeave * !open -a Terminal"'

The --nomru switch ensures that the commit message is not added to the Most Recently Used file menu (requires Snapshot 57 or later). The -c .. switch ensures that Terminal gets focus again after closing the commit message. (Note that you need to put the mvim script in your path for this to work.)

Why MacVim, when not launched via the Terminal.app, may not pick up my $PATH (or other variables)?

The problem, rather complicated, seems to stem when using zsh as the default shell for the system (it can be set in the System Preferences). A lengthy description of the problem can be found here but the quick solution involves two steps: set your PATH (or any other variable you may need) in ~/.zprofile and clone (if not already present) /etc/zshenv to /etc/zprofile. The steps can be achieved, assuming you have your PATH set in ~/.zshrc with the commands

cat .zshrc | grep "export PATH" >> .zprofile
sudo mv /etc/zshenv /etc/zprofile

Be careful not to override /etc/zprofile. Try to restart MacVim (not from the Terminal) and check for the results.

There is a caveat: when using Terminal.app, all the variables set in .zprofile and .zshrc will contain duplicate items. To fix it add typeset -U name_of_the_variable to your .zshrc.

My question is not answered in this FAQ. Where can I ask for help?

Please consult the Troubleshooting guide before asking for help! After doing so you may post your question to the vim_mac Google Group if it is MacVim related. General questions about using Vim should be posted to the vim_use Google Group.

Note that you do not need to subscribe to email notifications when signing up for either of these groups. You can read the groups online if you would rather keep your inbox clean. These groups are moderated so your first post may take up to a day before it arrives to the group (subsequent posts should show up within a few minutes).

Please read the guidelines before posting to either of these groups.