Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pycharm utils.py not getting syntax highlight

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?

like image 903
Vaibhav Mishra Avatar asked Nov 14 '12 07:11

Vaibhav Mishra


People also ask

How do I enable syntax highlighting in PyCharm?

Enable semantic highlightingPress Ctrl+Alt+S to open the IDE settings and select Editor | Color Scheme | Language Defaults | Semantic highlighting. Select the Semantic highlighting checkbox and customize the color ranges if necessary.

How do I enable syntax highlighting in Python?

You can change the syntax highlighting theme by clicking Options > Configure IDLE and switching to the Highlights tab.

Does PyCharm have syntax highlighting?

Syntax highlightingThe PyCharm editor respects highlighting of the keywords, comments, parameters, type hints and so on. The particular highlighting colors are defined in the Editor | Color Scheme page of the Settings/Preferences dialog.

What is Python syntax highlighting?

Syntax highlighting is a feature of text editors that are used for programming, scripting, or markup languages, such as HTML. The feature displays text, especially source code, in different colours and fonts according to the category of terms.


3 Answers

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

  • You can also use Revert File Type Override / Override File Type file context menu actions.
like image 115
CrazyCoder Avatar answered Oct 19 '22 07:10

CrazyCoder


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.

like image 33
Chris Avatar answered Oct 19 '22 06:10

Chris


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).

like image 2
Koyasha Avatar answered Oct 19 '22 08:10

Koyasha