How to run mvim (MacVim) from Terminal?

前端 未结 12 894
北荒
北荒 2020-11-30 15:55

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 d

相关标签:
12条回答
  • 2020-11-30 16:49

    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'

    0 讨论(0)
  • 2020-11-30 16:49

    I'd seriously recommend installing MacVim via MacPorts (sudo port install MacVim).

    When installed, MacPorts automatically updates your profile to include /opt/local/bin in your path, and so when mvim is installed as /opt/local/bin/mvim during the install of MacVim you'll find it ready to use straight away.

    When you install the MacVim port the MacVim.app bundle is installed in /Applications/MacPorts for you too.

    A good thing about going the MacPorts route is that you'll also be able to install git too (sudo port install git-core) and many many other ports. Highly recommended.

    0 讨论(0)
  • 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)

    cp -v [MacVim_source_folder]/src/MacVim/mvim /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

    mvim -v
    

    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.

    cd ~
    mvim -v .profile
    

    include the alias command in there and save it.

    That's it.

    0 讨论(0)
  • 2020-11-30 16:57

    If you have homeBrew installed, this is all you have to do:

    brew install macvim
    brew linkapps
    

    Then type mvim in your terminal to run MacVim.

    0 讨论(0)
  • 2020-11-30 16:59

    This works for me:

    λ brew link --overwrite macvim
    Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created
    
    0 讨论(0)
  • 2020-11-30 16:59

    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 you brew linkapps:

    Unfortunately brew linkapps cannot behave nicely with e.g. Spotlight using either aliases or symlinks and Homebrew formulae do not build "proper" .app bundles that can be relocated. Instead, please consider using brew cask and migrate formulae using .apps to casks.

    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 or open -a MacVim from a terminal session.

    UPDATE: A bit of clarification about brew and brew cask. In a nutshell, brew handles software at the unix level, whereas brew cask extends the functionality of brew into the macOS domain for additional functionality such as handling the location of macOS app bundles. Remember that brew is also implemented on Linux so it makes sense to have this division. There are other resources that explain the difference in more detail, such as What is the difference between brew and brew cask? so I won't say much more here.

    0 讨论(0)
提交回复
热议问题