git - 当我在vim中填写git commit消息时如何在文件列表中显示不同的颜色
问题描述
当我填写提交消息时,我可以看到文件列表,但它们的颜色相同(新/修改/删除)
我在问文件列表突出显示,没有消息突出显示,而不是配置 git 提交编辑器颜色的重复问题
我只能得到标签名称是gitcommitSelectedFile
,如何区分它们?
第一张在我的vim里,第二张在vs代码里
解决方案
你可以通过修改来改变gitcommit.vim
你可以找到你gitcommit.vim
的syntax/
目录。
您可以在 vim 中轻松找到 vim 目录
:echo $VIMRUNTIME
。
在内部gitcommit.vim
,您必须找到要更改的组。
在我的设置中,它是gitcommitSelectedType
. 这是 gitcommitSelectedType 匹配 - 它\t\@<=[[:lower:]][^:]*[[:lower:]]:
用于匹配modified:
和new file:
提交模板。
syn match gitcommitSelectedType "\t\@<=[[:lower:]][^:]*[[:lower:]]: "he=e-2 contained containedin=gitcommitComment nextgroup=gitcommitSelectedFile skipwhite
举个简单的例子,我清除并为andgitcoomitSelectedType
添加新的匹配。(例如简单匹配。您可以自己使用正则表达式)gitcommitNew
gitcommitModified
syn clear gitcommitSelectedType
" match for new file and modified
syn match gitcommitNew "\t\@<=new file: " contained containedin=gitcommitComment nextgroup=gitcommitSelectedType skipwhite
syn match gitcommitModified "\t\@<=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 之后使用异常 - 但我不知道如何。也许你能找到它。
前
后
添加
此外,它将为将来添加。在这里检查
推荐阅读
- r - 如何省略负数的条目?
- javascript - Vue 组件不会使用 getter 数据重新加载(非响应式)
- android - 如何在 AndroidManifest.xml 中为 Android Deeplinking 注入主机和架构
- java - 索引大文本文件的最快方法
- javascript - CSS 更改时如何在不重新加载的情况下更新 JavaScript?
- firebase - 文本注释应用程序的 Cloud Firestore 架构
- amazon-web-services - FilterExpression 仅适用于 DynamoDB 查询中的比较器“=”
- php - 如何将 api_token 参数更改为一些自定义参数,如 api_key 或 key
- java - 如果 MANIFEST.MF 不存在,主类的定义是什么
- kubernetes - 节点无法加入集群 K8S onprem