PyCharm 2016.3 Help

Using TextMate Bundles

On this page:

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.

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

Prerequisites

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 (where TextMate Bundles has been supported) or higher. In this tutorial, PyCharm 2016.1 is used.
  • Before you start working with TextMate Bundles, make sure that the TextMate bundle support plugin is enabled. The plugin is bundled with PyCharm and is activated by default. If it is not, enable the plugin as described in Enabling and Disabling Plugins.

    /help/img/idea/py_textmatebundles_plugin.png

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 /help/img/idea/settings.png, and under the Editor node, click TextMate Bundles. Then, in the TextMate Bundles area, click /help/img/idea/new.png, and locate the desired bundle on your hard disk:

/help/img/idea/py_textmatebundles_import.png

Click OK to apply changes. The Shell Script bundle appears in the list of recognized bundles, and its local path is visible to the right:

/help/img/idea/py_textmatebundles_import_result.png

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:

/help/img/idea/py_textmatebundles_color.png

Extension conflicts

Suppose you've imported a bundle that runs into a conflict with the existing file types. The conflict is immediately reported:

/help/img/idea/py_textmatebundles_import_existing.png

Clicking the Show details link opens the dialog box that gives you the chance to unregister the required extensions from the native file types:

/help/img/idea/py_textmatebundles_import_extension_conflicts.png

The node Files supported via TextMate Bundles now shows the new extensions (.htm, .html), and the node HTML lacks these extensions:

/help/img/idea/py_textmatebundles_import_new_file_types.png

Testing

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:

/help/img/idea/py_textmatebundles_highlight.png

See Also

Last modified: 23 November 2016