Search code examples
pythonpycharm

Comment color based on keyword in PyCharm


PyCharm has a feature that colors your comments yellow if they include TODO or FIXME keywords. What is the way to add more keywords to the list and change the colors based on the keyword?

Example:

enter image description here


Solution

  • In PyCharm:

    1. Press CTRL+ALT+S or navigate to Preferences/Settings
    2. Search TODO or go to Editor/TODO
    3. Add a pattern using the + button. For example, the pattern for ERROR keyword would be \berror\b.*. It can also be any other regex pattern. \b - word boundaries; .* - zero or more characters.
    4. Unselect Use color scheme TODO default colors and change the foreground color (ex. C00000 - red)
    5. Press OK and Apply

    Results:

    Results

    Settings:

    Settings

    Example ERROR pattern (red):

    Pattern