当前位置:   article > 正文

配置 Git 默认编辑器为 Vim_git默认编辑器

git默认编辑器

配置 Git 默认编辑器为 Vim

Ubuntu 系统中,Git 终端默认的编辑器为 GNU nano,修改为 Vim 编辑器。

1. GNU nano

Overview of nano’s shortcuts
https://www.nano-editor.org/dist/latest/cheatsheet.html

yongqiang@yongqiang:~/yongqiang_work/kmeans$ git commit --amend
  • 1

在这里插入图片描述

^ 表示键盘上的 Ctrl 键。

Ctrl+S: Save current file - 保存
Ctrl+O: Offer to write file (Save as) - 另存为 / 写入当前文件至磁盘
Ctrl+X: Close buffer, exit from nano - 关闭当前文件缓冲区 / 离开 nano

2. 文本编辑器

Now that your identity is set up, you can configure the default text editor that will be used when Git needs you to type in a message. If not configured, Git uses your system’s default editor.
既然用户信息已经设置完毕,你可以配置默认文本编辑器了,当 Git 需要你输入信息时会调用它。如果未配置,Git 会使用操作系统默认的文本编辑器。

If you want to use a different text editor, such as Emacs, you can do the following:

$ git config --global core.editor emacs
  • 1

On a Windows system, if you want to use a different text editor, you must specify the full path to its executable file. This can be different depending on how your editor is packaged.
在 Windows 系统上,如果你想要使用别的文本编辑器,那么必须指定可执行文件的完整路径。它可能随你的编辑器的打包方式而不同。

In the case of Notepad++, a popular programming editor, you are likely to want to use the 32-bit version, since at the time of writing the 64-bit version doesn’t support all plug-ins. If you are on a 32-bit Windows system, or you have a 64-bit editor on a 64-bit system, you’ll type something like this:

$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
  • 1

Vim, Emacs and Notepad++ are popular text editors often used by developers on Unix-based systems like Linux and macOS or a Windows system. Please find specific instructions for how to set up your favorite editor with Git in git config core.editor commands.

3. Vim

配置 Git 默认编辑器为 Vim。

yongqiang@yongqiang:~/yongqiang_work/kmeans$ git config --global core.editor vim
yongqiang@yongqiang:~/yongqiang_work/kmeans$
yongqiang@yongqiang:~/yongqiang_work/kmeans$ cat ~/.gitconfig
[user]
        email = ******@163.com
        name = ******@163.com
[core]
        editor = vim
yongqiang@yongqiang:~/yongqiang_work/kmeans$
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

References

[1] Yongqiang Cheng, https://yongqiang.blog.csdn.net/

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/煮酒与君饮/article/detail/917287
推荐阅读
相关标签
  

闽ICP备14008679号