当我填写提交消息时,我可以看到文件列表,但它们的颜色相同(new/modify/del)
我要求文件列表突出显示,没有消息突出显示,而不是Configure git commit editor colors的重复问题
我只能获取标签名称为gitcommitSelectedFile
,如何区分它们?
第一张图片在我的vim中,第二张图片在vs code中
最佳答案
可以通过修改gitcommit.vim
来更改
您可以找到您的gitcommit.vim
在syntax/
目录。
you can easily find vim dir by
:echo $VIMRUNTIME
inside your vim.
内部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
举个简单的例子,我清除 gitcoomitSelectedType
并为 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 之后使用异常 - 但我不知道如何。也许你能找到它。
之前
之后
添加
此外,它将在未来添加。检查here
关于git - 在vim中填写git提交消息时如何在文件列表中显示不同的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53590727/