将git默认的编辑器设置为vin

git默认编辑器现状

如下,很多linux发行版,未加修改的情况下,git的默认编辑器使用起来不太方便

复制代码
Signed-off-by: root <root@xxx.COM>

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Committer: root <root@xxx.COM>
#
# On branch master
#
# Initial commit
#
# Changes to be committed:
#       new file:   1.tex
#











^G Get Help    ^O Write Out   ^W Where Is    ^K Cut Text    ^J Justify     ^C Cur Pos     M-U Undo       M-A Mark Text
^X Exit        ^R Read File   ^\ Replace     ^U Paste Text  ^T To Spell    ^_ Go To Line  M-E Redo       M-6 Copy Text

方法一:通过命令行设置

你可以使用 git config 命令来设置 Vim 为默认的编辑器。这个命令可以在你的仓库级别(只影响当前仓库)、全局级别(影响所有仓库)或系统级别(影响所有用户)上设置。

为当前仓库设置 Vim 为默认编辑器

复制代码
~ # git config core.editor "vim"

为所有仓库(全局)设置 Vim 为默认编辑器

复制代码
~ # git config --global core.editor "vim"

为系统上所有用户设置 Vim 为默认编辑器(需要管理员权限):

复制代码
~ # git config --system core.editor "vim"

方法二:通过环境变量设置

另一种设置默认编辑器的方法是设置环境变量 EDITOR。这会影响所有需要编辑器的程序,包括 Git。

在 Bash 中设置(仅对当前会话有效)

复制代码
~ # export EDITOR=vim

在 Bash 中永久设置

export EDITOR=vim 添加到你的 ~/.bashrc~/.bash_profile 文件中,然后重新加载配置文件(通过运行 source ~/.bashrc 或重新登录)。

复制代码
~ # git config --system core.editor "vim"
相关推荐
打不了嗝 ᥬ᭄1 天前
Git 原理与使用
git·gitee
m0_614619061 天前
花了一下午学 Git,整理了一份学习笔记
笔记·git·学习
Codiggerworld1 天前
Vim的语法:删除、复制、粘贴,像说话一样自然
编辑器·vim·excel
AGV算法笔记1 天前
解决Git> git add -A -- fatal: CRLF would be replaced by LF in Test/Test.cpp
git
刘延林.1 天前
Visual Studio Code+PlatformIO + ESP32-S3 + Arduino 框架点亮一个小的led灯-测试
ide·vscode·编辑器
Dontla1 天前
VSCode插件Git Graph介绍(Git可视化管理分支、可视化Git)
ide·git·vscode
Echoo华地1 天前
用git diff快速比较文件夹差异并生成报告
linux·git·unix·repository·diff·branch
勤劳打代码1 天前
防微杜渐 —— 为什么一次 Sync 会变成一次 merge?
git·团队管理
dyxal1 天前
Windows 下 Git 离线安装与 VS Code 便携版集成完全指南
windows·git·elasticsearch
K3v1 天前
【git】自动化合并推送脚本
git·自动化