Pycharm utils.py not getting syntax highlight

Syntax HighlightingPycharm

Syntax Highlighting Problem Overview


I have several django projects and several different files with name utils.py, however pycharm treats them as simple .txt files with no syntax highlighting or any other kind of parsing, how can I fix this?

Syntax Highlighting Solutions


Solution 1 - Syntax Highlighting

Please see File | Settings (Preferences on Mac) | Editor | File Types.

Look for your file name mapped to the Text type or to the Auto-detect file type by content type.

Remove the incorrect mapping and it will fix the issue.

If you still can't find the wrong mapping in the IDE settings, locate the options/filetypes.xml file in the Configuration directory. Close the IDE and either edit this file to remove the incorrect mapping or delete this file to reset all the file types to the defaults.

text files

Solution 2 - Syntax Highlighting

As CrazyCoder answered, my file also landed in an unintended association. In my case it was "Auto-detect file type by content". You can just try to add your file to the desired file type (e.g. Python) and PyCharm will automatically try to move the association.

Solution 3 - Syntax Highlighting

FYI, a quick action to reassociate a file's type will be available in the context menu of the Project tool window in IntelliJ IDEA 2021.2 (EAPs should be available publicly around May 2021).

Solution 4 - Syntax Highlighting

In my case I had to right click the file in question (a django migration) and select Mark as Python. I probably clicked Mark as Plain Text before by mistake.

Solution 5 - Syntax Highlighting

I actually solved this by going to the Project section , and then clicking Override File Type by right clicking on the specific file. Then I selected the type of the file from the list of available file types.

That worked

Solution 6 - Syntax Highlighting

For me, the file somehow forgot its type. This can be overridden by

Right click the file name --> Override File Type --> Select file type.

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionVaibhav MishraView Question on Stackoverflow
Solution 1 - Syntax HighlightingCrazyCoderView Answer on Stackoverflow
Solution 2 - Syntax HighlightingChrisView Answer on Stackoverflow
Solution 3 - Syntax HighlightingKoyashaView Answer on Stackoverflow
Solution 4 - Syntax HighlightingavlnxView Answer on Stackoverflow
Solution 5 - Syntax HighlightingSsali JonathanView Answer on Stackoverflow
Solution 6 - Syntax HighlightingGulzarView Answer on Stackoverflow