当我在vim中填写git commit消息时,如何在文件列表中显示不同的颜色

问题描述 投票:2回答:1

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

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

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

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

git vim syntax-highlighting git-commit color-scheme
1个回答
3
投票

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

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

您可以在vim内轻松找到:echo $VIMRUNTIME的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并为gitcommitNewgitcommitModified添加新的匹配。 (例如,简单匹配。您可以使用正则表达式)

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之后使用异常 - 但我不知道如何。也许你可以找到它。

Before

Before change color

After

enter image description here

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

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.