如何从终端运行mvim (MacVim) ?

时间:2021-08-05 02:45:13

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?

我已经安装了MacVim,我正在尝试将它设置为Git(版本控制)的编辑器,但是我不能从命令行运行“mvim”,因为它不被识别。如何设置mvim,以便从终端运行它?

12 个解决方案

#1


184  

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.

在.bz2文件的根目录中应该有一个名为mvim的脚本。将其复制到您的$PATH中(/usr/local/bin将很好),您应该进行排序。

#2


193  

I don't think I'd to add anything to the path, did

我想我不会在这条路上添加任何东西。

brew install macvim

mvim -v

should then open macvim in the terminal, you can also go ahead and alias that

然后在终端打开macvim,你也可以继续使用别名吗?

alias vim='mvim -v'

#3


103  

If you go the brew route, the best way to install would be:

如果你选择酿造路线,最好的安装方式是:

brew install macvim --with-override-system-vim

That will provide mvim, vim, vi, view, etc. in /usr/local/bin (all symlinked to the copy in the Cellar). This also removes the need to create any aliases and also changes your vi, vim, etc. to all use the same Vim distribution as your MacVim.

这将在/usr/local/bin中提供mvim、vim、vi、视图等(所有与该副本在地窖中对应)。这也消除了创建任何别名的需要,同时也更改了vi、vim等所有使用与您的MacVim相同的vim分布。

#4


43  

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 to export 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.

另外,如果您想使用MacVim(或GVim)作为$VISUAL或$EDITOR,您应该知道,默认的MacVim将从父进程派生一个新进程,从而导致MacVim返回值无法到达父进程。这可能会混淆其他应用程序,但是Git似乎检查了临时提交消息文件的状态,该文件绕过了这个限制。一般来说,导出VISUAL='mvim -f'以确保MacVim不会在调用时调用一个新进程,这是一种很好的做法,它应该在使用shell环境时给您想要的东西。

#5


17  

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

如果你已经安装了homeBrew,这就是你要做的:

brew install macvim
brew linkapps

Then type mvim in your terminal to run MacVim.

然后在终端中输入mvim来运行MacVim。

#6


16  

If you already have macVim installed: /Applications/MacVim.app/Contents/MacOS/Vim -g will give you macVim GUI.

如果您已经安装了macVim: /应用程序/ macVim。app/内容/MacOS/Vim -g会给你macVim GUI。

just add an alias.

只需添加一个别名。

i use gvim because that is what i use on linux for gnome-vim.

我使用gvim,因为这是我在linux中使用gnome-vim的方法。

alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'

别名gvim = ' /应用程序/ MacVim。应用程序/内容/ MacOS / Vim - g”

#7


11  

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)

在构建Macvim后,我将mvim复制到我的$PATH目的地之一(在本例中,我选择/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时,它现在被识别了,但是有一件烦人的事情。它打开了视觉MacVim窗口,而不是终端的。要做到这一点,必须调用。

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:

为了确保每次你调用mvim时,你不需要记住添加“-v”,你可以创建一个别名:

alias mvim='mvim -v'

别名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.

但是,这个别名只会在终端的这个会话中保留。要在每次打开终端窗口时执行此别名,必须将其包含在.profile文件中。概要文件应该在您的主目录中。如果不是,就创建它。

cd ~
mvim -v .profile

include the alias command in there and save it.

在其中包含别名命令并保存它。

That's it.

就是这样。

#8


11  

I'm adding Bard Park's comment here for that was the real answer for me:

我在这里加上了巴德公园的评论这是我真正的答案:

Since mvim is simply a shell script, you can download it directly from the MacVim source at GitHub here: http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim

因为mvim只是一个shell脚本,所以您可以直接从GitHub上的MacVim源代码下载它:http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim。

#9


8  

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

我强烈建议通过MacPorts (sudo端口安装MacVim)安装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.

安装时,MacPorts会自动更新您的概要文件,以便在您的路径中包含/opt/local/bin,因此,当mvim在安装MacVim时被安装为/opt/local/bin/mvim时,您会发现它可以直接使用了。

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

当你安装MacVim端口的MacVim。app bundle也为你安装/应用/MacPorts。

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.

走MacPorts路线的一个好处是你也可以安装git (sudo端口安装git-core)和其他许多端口。强烈推荐。

#10


8  

Assume MacVim is installed in the Application folder.

假设MacVim安装在应用程序文件夹中。

Instead of adding MacVim path to your environment, create a link by typing this in terminal:

不要将MacVim路径添加到您的环境中,而是通过在终端键入这个链接来创建一个链接:

sudo ln -s /Applications/MacVim.app/Contents/bin/mvim /usr/local/bin/mvim

sudo ln - s /应用程序/ MacVim。应用程序/内容/ bin / mvim /usr/local/bin/mvim

Then, open a new terminal window/tab and type mvim.

然后,打开一个新的终端窗口/制表符和类型mvim。

#11


0  

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:

对于Mac .应用程序包,您应该通过cask安装它们,如果可用,因为使用符号链接会导致问题。你甚至可能会收到以下警告:

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.

不幸的是,brew应用程序不能很好地运行,比如使用别名或符号链接,而Homebrew公式不构建“适当”的应用程序包。相反,请考虑使用brew cask和迁移公式。

For MacVim, you can install with:

对于MacVim,您可以安装:

brew cask install macvim

啤酒桶安装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.

然后,您应该能够启动MacVim,就像您做任何其他macOS应用程序,包括mvim或open -a MacVim从一个终端会话。

#12


0  

This works for me:

这工作对我来说:

λ brew link --overwrite macvim
Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created

#1


184  

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.

在.bz2文件的根目录中应该有一个名为mvim的脚本。将其复制到您的$PATH中(/usr/local/bin将很好),您应该进行排序。

#2


193  

I don't think I'd to add anything to the path, did

我想我不会在这条路上添加任何东西。

brew install macvim

mvim -v

should then open macvim in the terminal, you can also go ahead and alias that

然后在终端打开macvim,你也可以继续使用别名吗?

alias vim='mvim -v'

#3


103  

If you go the brew route, the best way to install would be:

如果你选择酿造路线,最好的安装方式是:

brew install macvim --with-override-system-vim

That will provide mvim, vim, vi, view, etc. in /usr/local/bin (all symlinked to the copy in the Cellar). This also removes the need to create any aliases and also changes your vi, vim, etc. to all use the same Vim distribution as your MacVim.

这将在/usr/local/bin中提供mvim、vim、vi、视图等(所有与该副本在地窖中对应)。这也消除了创建任何别名的需要,同时也更改了vi、vim等所有使用与您的MacVim相同的vim分布。

#4


43  

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 to export 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.

另外,如果您想使用MacVim(或GVim)作为$VISUAL或$EDITOR,您应该知道,默认的MacVim将从父进程派生一个新进程,从而导致MacVim返回值无法到达父进程。这可能会混淆其他应用程序,但是Git似乎检查了临时提交消息文件的状态,该文件绕过了这个限制。一般来说,导出VISUAL='mvim -f'以确保MacVim不会在调用时调用一个新进程,这是一种很好的做法,它应该在使用shell环境时给您想要的东西。

#5


17  

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

如果你已经安装了homeBrew,这就是你要做的:

brew install macvim
brew linkapps

Then type mvim in your terminal to run MacVim.

然后在终端中输入mvim来运行MacVim。

#6


16  

If you already have macVim installed: /Applications/MacVim.app/Contents/MacOS/Vim -g will give you macVim GUI.

如果您已经安装了macVim: /应用程序/ macVim。app/内容/MacOS/Vim -g会给你macVim GUI。

just add an alias.

只需添加一个别名。

i use gvim because that is what i use on linux for gnome-vim.

我使用gvim,因为这是我在linux中使用gnome-vim的方法。

alias gvim='/Applications/MacVim.app/Contents/MacOS/Vim -g'

别名gvim = ' /应用程序/ MacVim。应用程序/内容/ MacOS / Vim - g”

#7


11  

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)

在构建Macvim后,我将mvim复制到我的$PATH目的地之一(在本例中,我选择/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时,它现在被识别了,但是有一件烦人的事情。它打开了视觉MacVim窗口,而不是终端的。要做到这一点,必须调用。

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:

为了确保每次你调用mvim时,你不需要记住添加“-v”,你可以创建一个别名:

alias mvim='mvim -v'

别名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.

但是,这个别名只会在终端的这个会话中保留。要在每次打开终端窗口时执行此别名,必须将其包含在.profile文件中。概要文件应该在您的主目录中。如果不是,就创建它。

cd ~
mvim -v .profile

include the alias command in there and save it.

在其中包含别名命令并保存它。

That's it.

就是这样。

#8


11  

I'm adding Bard Park's comment here for that was the real answer for me:

我在这里加上了巴德公园的评论这是我真正的答案:

Since mvim is simply a shell script, you can download it directly from the MacVim source at GitHub here: http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim

因为mvim只是一个shell脚本,所以您可以直接从GitHub上的MacVim源代码下载它:http://raw.github.com/b4winckler/macvim/master/src/MacVim/mvim。

#9


8  

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

我强烈建议通过MacPorts (sudo端口安装MacVim)安装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.

安装时,MacPorts会自动更新您的概要文件,以便在您的路径中包含/opt/local/bin,因此,当mvim在安装MacVim时被安装为/opt/local/bin/mvim时,您会发现它可以直接使用了。

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

当你安装MacVim端口的MacVim。app bundle也为你安装/应用/MacPorts。

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.

走MacPorts路线的一个好处是你也可以安装git (sudo端口安装git-core)和其他许多端口。强烈推荐。

#10


8  

Assume MacVim is installed in the Application folder.

假设MacVim安装在应用程序文件夹中。

Instead of adding MacVim path to your environment, create a link by typing this in terminal:

不要将MacVim路径添加到您的环境中,而是通过在终端键入这个链接来创建一个链接:

sudo ln -s /Applications/MacVim.app/Contents/bin/mvim /usr/local/bin/mvim

sudo ln - s /应用程序/ MacVim。应用程序/内容/ bin / mvim /usr/local/bin/mvim

Then, open a new terminal window/tab and type mvim.

然后,打开一个新的终端窗口/制表符和类型mvim。

#11


0  

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:

对于Mac .应用程序包,您应该通过cask安装它们,如果可用,因为使用符号链接会导致问题。你甚至可能会收到以下警告:

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.

不幸的是,brew应用程序不能很好地运行,比如使用别名或符号链接,而Homebrew公式不构建“适当”的应用程序包。相反,请考虑使用brew cask和迁移公式。

For MacVim, you can install with:

对于MacVim,您可以安装:

brew cask install macvim

啤酒桶安装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.

然后,您应该能够启动MacVim,就像您做任何其他macOS应用程序,包括mvim或open -a MacVim从一个终端会话。

#12


0  

This works for me:

这工作对我来说:

λ brew link --overwrite macvim
Linking /usr/local/Cellar/macvim/8.0-146_1... 12 symlinks created