Git commit -a 打开 GNU nano 2.2.6 我应该如何更改它以打开 Vim?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19691395/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 09:17:09  来源:igfitidea点击:

Git commit -a opens GNU nano 2.2.6 How should I change it to open Vim instead?

gitvimeditorgnunano

提问by Ketan Deshmukh

I am trying to add a commit message to my changes using

我正在尝试使用

git commit -a 

OR just plain

或者只是简单的

git commit

this somehow opens GNU Nano 2.2.6 editor and I am not at all comfortable with it. So the question is :

这以某种方式打开了 GNU Nano 2.2.6 编辑器,我对它一点也不舒服。所以问题是:

How can I modify my settings so that it always opens with VIM ?

如何修改我的设置以使其始终使用 VIM 打开?

What I already have done is inserting following line in my ~/.bash_profile

我已经做的是在我的 ~/.bash_profile 中插入以下行

set EDITOR = vim

Please help !

请帮忙 !

回答by StevenPatz

You can set it from the command line or in your .gitconfig

您可以从命令行或在您的 .gitconfig

git config --global core.editor vim

回答by Ingo Karkat

To make Vim the default editor for Git only, see HST's answer. However, you probably want to have Vim as the default for allapplications.

要使 Vim 仅成为 Git 的默认编辑器,请参阅 HST 的回答。但是,您可能希望将 Vim 作为所有应用程序的默认设置。

That can be done by

这可以通过

export EDITOR=vim

in your ~/.bash_profileor ~/.bashrc. The key is the export, otherwise the setting won't inherit to launched processes, like Git is.

在您的~/.bash_profile~/.bashrc. 关键是export,否则设置将不会继承到启动的进程,就像 Git 一样。