Skip to end of metadata
Go to start of metadata

What this tutorial is about

Projects can contain file types unknown to PyCharm. While PyCharm comes with the built-in support for many programming and scripting languages, you might want to have syntax highlighting for the project-specific languages. For example, a project can contain a shell script, or Perl; a configuration file can exist in a project for the infrastructure automation purposes. If you want to have syntax highlighting for these cases, use the powerful PyCharm's integration with the text editor TextMate.

This tutorial aims to walk you step by step through configuring PyCharm to use the TextMate Bundles, and editing files with the registered extensions.

What this tutorial is not about

Learning TextMate is out of scope of this tutorial. For information about TextMate, refer to the product documentation.

Before you start

Make sure that:

  • You have already downloaded bundles you want to use. You can, for example, find the bundles you want to install on GitHub or Subversion
  • You are working with PyCharm 2.7 or higher
  • TextMate bundles support plugin is enabled. This plugin comes bundled with PyCharm, and is enabled by default. To verify that the plugin is enabled, click on the main toolbar, and under the IDE Settings, click Plugins. See that the check box to the left of the plugin name is selected. If this check box is cleared, select it:

Importing bundles

Suppose you want PyCharm to highlight syntax of the Shell Script files. For this purpose, you have already downloaded the Shell Script TextMate Bundle. It now resides on your hard disk, and you only have to import this bundle into PyCharm.

OK, off we go. On the main toolbar, click , and under the IDE Settings, click TextMate Bundles. Then, in the TextMate Bundles area, click , and locate the desired bundle on your hard disk:

OK - the settings are applied. The Shell Script bundle appears in the list of recognized bundles, and its local path is visible to the right:

However, we have not yet defined which color scheme PyCharm will use to highlight Shell Script syntax. As you already know, PyCharm provides a number of color schemes, from the classic-looking ones to the fashionable dark schemes, like Darcula. Have a look at the color scheme mapping section in the lower part of the TextMate Bundles page. By default, the PyCharm's Default color scheme maps to the Mac Classic. If we want to use a different color scheme for our bundle, we can click the "Mac Classic" cell in the table of mappings, and select the desired scheme from the list of available ones. However, let's stick to the suggested scheme:

Adding file type

Most TextMate bundles come with a set of file extensions they can handle. The Shell Script bundle registers common extensions such as .sh, .bash, .zsh and so on. If not or if we want to make use of another file extension which maps to the TextMate bundle, we can add the missing extensions.

To do this, still in the Settings dialog, click File Types. On this page, in the Recognized File Types area, locate the entry Files supported via TextMate Bundles. In the Registered Patterns area below, we see all the file types, supported by the Shell Script bundle. If you want to add a missing extension, then, in the Registered Patterns area, click , and type the file extension in the Add Wildcard dialog box.

If all your extensions are in place, apply changes and close the Settings dialog box: OK - OK - the changes are applied, the dialog box closes.

Testing it

Once a TextMate bundle is added, PyCharm provides syntax highlighting for the file types registered with the bundle. Here's a sample script that uses the Shell Script TextMate bundle we've cloned earlier:

Your Rating: Results: BrokenPartially brokenWorksStableNo problems at all 3 rates
Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.