将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"
相关推荐
flytalei几秒前
逐浪笔记 GitOps 实战:Jenkins 构建、Argo CD 同步与 Git 回滚
笔记·git·jenkins
叼烟扛炮42 分钟前
Linux 学习笔记(七):软件安装与 Vim 编辑器极速入门
linux·学习·编辑器
幸运小圣1 小时前
fs 模块完全指南:文件读写、移动删除与文件夹操作(新手友好)【Node.js】
node.js·编辑器·vim
熊出没2 小时前
CommitLoom 使用教程:在 IntelliJ IDEA 中自动生成 Git 提交信息
java·git·intellij-idea
IOT那些事儿16 小时前
Git报错:Could not get HEAD hash
git·hash·head
纪伊路上盛名在18 小时前
windows 配置vscode x11转发
ide·vscode·编辑器
杜哥无敌18 小时前
Git Bash + acme.sh 实现 SSL 证书自动续签(完整指南)
git·bash·ssl
nunumaymax1 天前
Git教程
git
阿萨德528号1 天前
IDEA 项目 SVN 配置消失、版本控制变成 Git 且无 VCS 菜单的解决办法
git·svn·intellij-idea
hkj88081 天前
VsCode的使用
ide·vscode·编辑器