I have MacVim installed and I am trying to set it up as the editor for Git (version control), but I can't run 'mvim' from the command line as it isn't recognised. How do I setup mvim so I can run it from Terminal?
相关问题
- How to get the return code of a shell script in lu
- Invoking Mirth Connect CLI with Powershell script
- Xcode debugger displays incorrect values for varia
- Is there a way to report errors in Apple documenta
- Advice for supporting both Mac and Windows Desktop
If you already have macVim installed:
/Applications/MacVim.app/Contents/MacOS/Vim -g
will give you macVim GUI.just add an alias.
i use
gvim
because that is what i use on linux for gnome-vim.alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'
For Mac
.app
bundles, you should install them via cask, if available, as using symlinks can cause issues. You may even get the following warning if youbrew linkapps
:For MacVim, you can install with:
brew cask install macvim
You should then be able to launch MacVim like you do any other macOS app, including
mvim
oropen -a MacVim
from a terminal session.I'm adding Bard Park's comment here for that was the real answer for me:
In addition, if you want to use MacVim (or GVim) as
$VISUAL
or$EDITOR
, you should be aware that by default MacVim will fork a new process from the parent, resulting in the MacVim return value not reaching the parent process. This may confuse other applications, but Git seems to check the status of a temporary commit message file, which bypasses this limitation. In general, it is a good practice toexport VISUAL='mvim -f'
to ensure MacVim will not fork a new process when called, which should give you what you want when using it with your shell environment.There should be a script named mvim in the root of the .bz2 file. Copy this somewhere into your $PATH ( /usr/local/bin would be good ) and you should be sorted.
Here's what I did:
After building Macvim I copied mvim to one of my $PATH destinations (In this case I chose /usr/local/bin)
Then when you invoke mvim it is now recognised but there is an annoying thing. It opens the visual MacVim window, not the one in terminal. To do that, you have to invoke
To make sure every time you call mvim you don't have to remember to add the '-v' you can create an alias:
alias mvim='mvim -v'
However, this alias will only persist for this session of the Terminal. To have this alias executed every time you open a Terminal window, you have to include it in your .profile The .profile should be in your home directory. If it's not, create it.
include the alias command in there and save it.
That's it.