简体   繁体   English

在Vim中更改Python for循环的颜色

[英]Changing colors of a Python for-loop in Vim

I've just started learning python and I'm using MacVim as my editor with the Jellybeans color scheme. 我刚刚开始学习python,我正在使用MacVim作为我的编辑器,使用Jellybeans配色方案。 When I write a for-loop in python the 'for' is colored blue(ish) while the 'in' is not. 当我在python中写一个for循环时,'for'的颜色为蓝色(ish),而'in'则不是。 I see in other themes they are both colored the same. 我在其他主题中看到它们都是相同的。 How do I edit the jellybeans theme to get that? 如何编辑软糖主题以获得它?

Here's a picture showing what I mean: 这是一张显示我的意思的图片:
图片显示</ code>中的<code>未突出显示

Vim's python syntax file defines in as part of the pythonOperator syntax group. Vim的Python语法文件定义 in的一部分pythonOperator语法组。 The pythonOperator group is linked to the built-in Operator group, which is (by default) linked in turn to Statement . pythonOperator链接到内置的Operator组,该组默认情况下依次链接到Statement

Jellybeans instead links Operator to Normal to get uncolored symbolic operators ( + , * , etc) without changing Statement . Jellybeans改为 Operator 连接Normal以获得未着色的符号运算符( +*等)而不更改Statement

Adding a special case link directly from pythonOperator to Statement restores the coloring. 直接从pythonOperator添加一个特殊的case链接到Statement恢复着色。


tl;dr I fixed it . tl;博士我修好了 Grab a new copy from the GitHub repo . GitHub仓库中获取新副本。

There are several ways to "accomplish" that. 有几种方法可以“完成” Could you give the link from where you downloaded the aforementioend Jellybeans color scheme? 你能给出你下载上述Jellybeans配色方案的链接吗?

My first look would be whether in the colorscheme there is something that overwrites the "in" element into a different color than the "for" element. 我的第一个看法是,在colorscheme中是否有一些东西会将“in”元素覆盖为与“for”元素不同的颜色。 If there is nothing inside, then it must be something with the syntax highlighting for python. 如果里面没有任何东西,那么它必须是python语法高亮的东西。

But in that case, that would also show with other color schemes as well. 但在这种情况下,这也将与其他配色方案一起显示。

To change the color of the loops in only python, add this to your .vimrc after you set the color-scheme 要仅在python中更改循环的颜色,请在设置颜色方案后将其添加到.vimrc

autocmd FileType python hi Repeat guifg=#hexnumber

with #hexnumber the gui code for the color you want to change the color of just the operators replace Repeat with operator 使用#hexnumber你想要改变颜色的颜色的gui代码替换使用运算符重复

edit: 编辑:

I might have misunderstood your question loops are in the highlight group repeat and in is in the hi-group operator both belong to the group statement so if statement is the only one set in you color-scheme you have to set Repeat and operator yourself 我可能误解了你的问题循环在高亮组重复和在hi-group运算符中都属于组语句所以如果语句是你在颜色方案中设置的唯一一个你必须自己设置重复和运算符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM