33

I have a Python project, and I use WebStorm as my Editor. The problem is that Python's syntax doesn't get colored.

How can I display Python pages with a nice syntax? I am not searching more than than. I'm not going to develop pages in Python, but I do want them to get displayed nicely in Webstorm.

3 Answers 3

57

Your ONLY option in WebStorm is to use TextMate bundles support plugin with Python bundle -- it will provide syntax highlighting (no completion or syntax checking etc).

This official article (with pictures) is for PhpStorm, but it should work the same for WebStorm as well: http://confluence.jetbrains.com/display/PhpStorm/TextMate+Bundles+in+PhpStorm

There are several TextMate bundles available for Python: https://github.com/textmate?utf8=%E2%9C%93&q=python

Alternative solution: migrate to PyCharm Pro -- it does all what WebStorm does + Python.


UPDATE: 2019-06-18

2019.2 version will come bundled with syntax highlighting for about 20 languages (all done via the aforementioned TextMate bundles plugin).

https://blog.jetbrains.com/webstorm/2019/05/webstorm-2019-2-eap/

In WebStorm 2019.2, we’re adding syntax highlighting for over 20 different programming languages, including PHP, Python, Ruby, and Java. It just works – no additional configuration needed.

With this change we want to improve the experience of our users who occasionally have to look through some code written in different languages that are not supported in WebStorm. But WebStorm is still primarily an IDE for JavaScript and TypeScript developers, so we don’t plan to extend the support for these other languages beyond syntax highlighting.

Syntax highlighting for these languages is built using TextMate grammars, and WebStorm bundles a collection of grammar file for different languages. Currently they are shipped as part of the TextMate Bundles plugin (so you can see a full list of supported languages under Preferences | Editor | TextMate Bundles), but they are going to be moved to the IntelliJ Platform soon.

enter image description here

enter image description here

4
  • 1
    I cannot figure out how to do this for the life of me in webstorm? where the hell do I import the python.tmbundle to? Aug 14, 2015 at 23:56
  • 1
    @MatthewHarwood it's under Editor -> TextMate Bundles. I found by searching webstorm preferences in the top left search box
    – warren
    Sep 22, 2015 at 7:18
  • I see the Python.tmbundle but every time I click on it I get an error: Can't read following bundles: path to Python.tmbundle... any ideas? Aug 2, 2016 at 18:26
  • 2
    well, apparently works on linux - very easy to install - just clone the textmate github repo locally (don't even need to build anything), then open Webstorm or PHPStorm or whatever, and go to settings -> editor -> textmate bundles, and point the GUI to the root of the Textmate Github project you just cloned. Voila. Now it's only syntax highlighting, and doesn't seem to provided any error prediction. Dec 31, 2016 at 20:46
11

You can use the Perl syntax which is very similar to Python.

  1. Go to Preferences => File Types
  2. Search for Perl
  3. Add *.py under Registered Patterns

Another option is to use PyCharm, the community version is free.

0

Python might be missing in Preferences -> Editor -> File Types. After adding the Python, make sure to add a *.py registered pattern.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.