Python Language Keywords not Highlighting


I am having a problem with Python language keywords highlighting. Specifically

  • in
  • or
  • and
  • \ (not technically a keyword)
  • is
  • not

I would expect Atom to highlight these keywords / characters similar to :

for a in b:
  if a is not c and q or r:

though this is what I am getting :

No syntax highlighting :frowning:

I was wondering if this was exclusive to me or it is worth opening an issue on the python-language package?

Python keywords not highlighting

Before you open an issue on the python-language package, first check to see if it is a syntax issue or a coloring issue. You can check to see what scopes a particular position is marked with by:

  1. Open the Developer Tools View > Developer > Toggle Developer Tools
  2. Switch to the Console tab
  3. Place your cursor at the position for which you want a scope check
  4. Execute the editor:log-cursor-scope command either from the Command Palette or keybinding (Cmd+Alt+P on OS X)

When I place the cursor after the “i” but before the “n” in the in keyword on the first line, the scope returned is: ["source.python", "keyword.operator.logical.python"]. So the python-language package is correctly recognizing the keyword as a keyword … just your syntax theme isn’t doing anything with it.

Here’s how the same code looks under my ya-railscasts-syntax package*:

* Not designed for public consumption. The Author reserves the right to make sweeping changes with no notice whatsoever. Use at your own risk. Wait 30 minutes before swimming. Do not look into laser with remaining good eye.

1 Like

Executing editor:log-cursor-scope resulted in ["source.python", "keyword.operator.logical.python"] so this a problem with my syntax theme.

I am currently using Solarized Dark. Switching to Solarized Light I the previously mentioned keywords are being highlighted. I have created an issue for this here.

Thanks for insight @leedohm. You are always extremely helpful :+1:


Upon forking atom/solarized-dark-syntax to try and fix this issue I installed Atom Color Highlight and reloaded my Atom. Everything now appears to be working fine.

Example :

1 Like

@dreid93 is anyone working on a pull for solarized? I have noticed that the colors used in the default atom/solarized-dark-syntax are incorrect for many languages. For example, the default html colors for solarized are not correct. This is also true with many other languages, I am currently working on a PR to send that will correct most of these inconsistencies


@dreid93 @leedohm I have created a pull request that corrects a lot of the issues people have been having with the solarized dark syntax theme.


Atom didn’t recognize the code as “Python”, so it might default to plain text. What worked for me was going to the bottom right corner of the editor. There I found 4 rectangular areas labeled “CRLF”, “UTF-8”, “plain text”, and “0 files”.
I clicked on “plain text” and then selected Python from the drop-down menu.
It changed the whole code to proper Python syntax highlighting.
Here’s what it looks like:

  1. In the Settings/Preferences dialog (Ctrl+Alt+S), go to Editor | Color Scheme | Language Defaults | Semantic highlighting.
  2. Select the Semantic highlighting checkbox and customize the color ranges if necessary