热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

开发笔记:当我在vim中填写gitcommit消息时,如何在文件列表中显示不同的颜色

篇首语:本文由编程笔记#小编为大家整理,主要介绍了当我在vim中填写gitcommit消息时,如何在文件列表中显示不同的颜色相关的知识,希望对你有一定的参考价值。

篇首语:本文由编程笔记#小编为大家整理,主要介绍了当我在vim中填写git commit消息时,如何在文件列表中显示不同的颜色相关的知识,希望对你有一定的参考价值。



当我正在填写提交消息时,我可以看到文件列表,但它们是相同的颜色(new / modify / del)

我问文件列表突出显示,没有消息突出显示,不重复Configure git commit editor colors的问题

我只能得到标签名称是gitcommitSelectedFile,如何区分它们?

第一张图片在我的vim中,第二张图片在vs代码中


答案

您可以通过修改gitcommit.vim进行更改

你可以在gitcommit.vim dir找到你的syntax/



您可以在vim内轻松找到:echo $VIMRUNTIME的vim目录。


gitcommit.vim里面,你必须找到你想要改变的群体。

在我的环境中,它是gitcommitSelectedType。这是gitcommitSelectedType匹配 - 它使用 @<=[[:lower:]][^:]*[[:lower:]]:在提交模板中匹配modified:new file:

syn match gitcommitSelectedType " @<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained cOntainedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite

举个简单的例子,我清除gitcoomitSelectedType并为gitcommitNewgitcommitModified添加新的匹配。 (例如,简单匹配。您可以使用正则表达式)

syn clear gitcommitSelectedType
" match for new file and modified
syn match gitcommitNew " @<=new file: " contained cOntainedin=gitcommitComment nextgroup=gitcommitSelectedType skipwhite
syn match gitcommitModified " @<=modified: "he=e-2 contained cOntainedin=gitcommitComment nextgroup=gitcommitModified skipwhite
" give other color type for these group
hi link gitcommitNew Type
hi link gitcommitModified Special
" add two groups we made to gitcommitSelected
syn region gitcommitSelected start=/^# Changes to be committed:/ end=/^#$|^#@!/ cOntains=gitcommitHeader,gitcommitHead,gitcommitSelectedType,gitcommitNew,gitcommitModified fold

也许有更好的解决方案 - 不使用组但在gitcommitSelectedType之后使用异常 - 但我不知道如何。也许你可以找到它。


Before

Before change color


After

enter image description here


此外,它将在未来添加。检查here



推荐阅读
author-avatar
唯一V5321_219
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有