问题
class Foo:
def __init__(self):
byte_string = 'newline:\n also newline:\x0a'
In PyCharm, how do I change the color of variables like "byte_string" in the example above? I don't see any place to change this in the "Python" section of the color settings.
回答1:
Unbelievable but true, I was answered by Pycharm staff that it is NOT possible to set custom variable color. Please all vote on: https://youtrack.jetbrains.com/issue/PY-8246
回答2:
PyCharm 2017.1 has "semantic highlighting". Give it a try.
It looks like this:
回答3:
To change the default color of variables in PyCharm (4.5.3, to be precise), take the following steps:
- Open the Preferences window.
- In the left sidebar, click on the node labeled Editor.
- Under Editor, click on the node labeled Colors & Fonts, then the sub-node, Language Defaults.
- If you're using a default color scheme, click the button labeled Save As, as PyCharm won't let you overwrite built-in color schemes.
- In the center of the window, you'll see a list of language elements. Based on your example, it looks like you want to change the appearance of local variables, so scroll to the item labeled Local variable, and click on it.
If you'd also like to change the color of global variables, or even of all identifiers, just scroll to the item labeled Global variables or Identifiers, as appropriate, and follow steps 5-7.
TL;DR: Edit local variable colors at Preferences > Editor > Colors & Fonts > Language Defaults > Local variable.
回答4:
The 2018 versions of Pycharm now support semantic highlighting, which applies colors to local and global variables.
Under
file, settings
Navigate to
Editor->Color Scheme->Language Defaults->Symantic higlighting
to change the colors that the editor uses for variables.
You'll probably need to save your own custom theme as mentioned in the Tutleman's comment. By default Pycharm gives a range of 5 colors to use, if you want all your variables to be the same color, then you can set all 5 colors to the same color.
edit: I undeleted this because it solved what I was looking for when you found question. I'm not sure why you decided to delete it? I believe this will solve the problem people are searching about when they find your post.
来源:https://stackoverflow.com/questions/31705927/how-to-change-variable-name-color