ctrl+shift+p filters: :st2 :st3 :win :osx :linux


by skuroda ALL

Persistent regular expression highlighting for Sublime Text 2


  • 2017.
  • github.​com
  • github.​com
  • 3 years ago
  • 2 hours ago
  • 8 years ago


  • Total 5K
  • Win 3K
  • Mac 2K
  • Linux 1K
May 27 May 26 May 25 May 24 May 23 May 22 May 21 May 20 May 19 May 18 May 17 May 16 May 15 May 14 May 13 May 12 May 11 May 10 May 9 May 8 May 7 May 6 May 5 May 4 May 3 May 2 May 1 Apr 30 Apr 29 Apr 28 Apr 27 Apr 26 Apr 25 Apr 24 Apr 23 Apr 22 Apr 21 Apr 20 Apr 19 Apr 18 Apr 17 Apr 16 Apr 15 Apr 14 Apr 13 Apr 12
Windows 0 1 0 0 0 2 0 1 2 0 0 0 0 0 7 1 0 1 0 2 0 1 0 2 0 0 0 0 0 0 1 0 1 1 0 0 0 0 0 0 0 1 0 0 0 0
Mac 0 0 0 0 0 1 1 0 0 0 0 0 2 1 1 1 0 1 0 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 0 0 1 0 1 2 0 0 0 1 0 1
Linux 0 0 0 0 0 1 0 0 0 1 2 1 0 0 1 0 0 0 0 0 0 2 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0




This plugin will allow you to create regular expressions that will highlight for all documents.



Clone or copy this repository into the packages directory. By default, they are located at:

  • OS X: ~/Library/Application Support/Sublime Text 2/Packages/
  • Windows: %APPDATA%/Roaming/Sublime Text 2/Packages/
  • Linux: ~/.config/sublime-text-2/Packages/


  • OS X: ~/Library/Application Support/Sublime Text 3/Packages/
  • Windows: %APPDATA%/Roaming/Sublime Text 3/Packages/
  • Linux: ~/.config/sublime-text-3/Packages/

Package Control

Installation through package control is recommended. It will handle updating your packages as they become available. To install, do the following.

  • In the Command Palette, enter Package Control: Install Package
  • Search for PersistentRegexHighlight




An array of hash entries used to determine what to highlight. For more information about these entries, please see Regex Settings.


A boolean value that is used to specify if highlighting is enabled.


A boolean value that specifies if highlighting should occur when a view is loaded.


A boolean value that specifies if highlighting should occur as modifications are made.


An array containing file patterns to ignore. Note these use Unix style patterns. Patterns are compared against the absolute path for the current file.


Maximum file size to run the the PersistentRegexHighlight on. Any value less than or equal to zero will be treated as a non limiting value. Default value is 0.


A list of absolute paths, specifying folders to run PersistentRegexHighlight. An empty list will result in PersistentRegexHighlight running on all files (unless limited by the disable_pattern setting).

Regex Settings


A string representing a pattern to match. Note that the regex setting must contain either pattern or pattern_scope. If both are specified, pattern will be used.


A string specifying a scope to highlight. These are scopes that exist in a .tmLanguage files. If multiple entries in the regex setting contain overlapping scopes, the first will be used. For example, if two entries are specified with different colors, one being constant.language and the other being constant.language.python, which ever appears first will be used to highlight. Note that the regex setting must contain either pattern or pattern_scope. If both are specified, pattern will be used.


An optional parameter where one can specify scopes which will never be matched by the pattern. It is Possible to specify more than one scope. They are separated by whitespace (' ').


An optional boolean value specifiying if the pattern should ignore case. This only applies if pattern is specified. By default, this is set to false.


An optional parameter specifying the color scope to use. Please note you should specify either color or color_scope. If both are specified, color_scope will be taken over color. This scope should already exist in your color scheme file. For more information, see Specifiying Highlight Color.


An optional parameter specifying a highlight color. Please note you should specify either color or color_scope. If both are specified, color_scope will be taken over color. The value for this entry should be in the form RRBBGG. By specifying this value, a new color scheme file will be generated. Please see Specifiying Highlight Color for more information about specifying a color and the generated file.


A boolean value specifying if the specified pattern should be underlined rather than highlighted. If this is set to “False”, the entry will be highlighted rather than underlined. This defaults to False.


An optional string specifying the underline style. This value is only used if underline is true. In addition, styles only apply for Sublime Text versions >= 3014. Valid Entries for this field are solid, squiggly, and stippled. Invalid entries will fall back to solid.

Sample Regex Entries

Example specifying various patterns.

    "regex": [{
        "pattern": "[Ff]oo",
        "color_scope": "color.scope.name",
        "ignore_case": true
    }, {
        "pattern_scope": "constant.language",
        "color_scope": "constant.language"
    }, {
        "pattern": "SomeUnderlinePattern",
        "underline": true

Example specifying a color scope.

    "regex": [{
        "pattern": "[Ff]oo",
        "color_scope": "color.scope.name",
        "ignore_case": true

Example specifying a color.

    "regex": [{
        "pattern": "Bar",
        "color": "00FF00",
        "ignore_case": false

Example for excluding a scope.

    "regex": [{
        "pattern": "\\t",
        "color": "FF3333",
        "ignore_case": true,
        "ignored_scopes": "text.plain example.scope.name"

Project Specific Settings

All of the above settings can also be specified as part of the project specific settings. These values override any previous values set by higher level settings (user and default). For example, specifying a new regex entry will only highlight entries specified as part of the project specific settings.

        "enabled": false

Specifying Highlight Color

You may specify colors in two ways. You may either specify a color scope or a hex color. See Regex Settings for information on color formatting.

Specifying Scope

Below is a sample entry for specifying a custom scope in the theme file. The scope 'regex.highlight.one' would be used to specify utilization of this coloring.

    <string>Regex Highlight</string>

Specifying Color

Specifying a value for the color key will generate a new color scheme file. This will take the contents of your current color scheme file and write it to Packages/User/ColorScheme/<color_scheme_name_here>. This is done to prevent polluting the default color scheme with the additional values. When this is done, you will be prompted with a dialog box to optionally change your color scheme file to the newly created one.


If you are having unexpected behaviors, please do not hesitate to create an issue. When you do, please include the console output, accessible through View -> Show Console or Ctrl/Cmd + ` by default.

Specifying a color

The current libraries included with Sublime Text 2 for some platforms are missing the pyexpat module. To temporarily fix this issue, you will need to place the Python library into the Sublime Library directory. If you already have Python 2.6, like ln -s /usr/lib/python2.6 [Sublime Text 2 Directory]/lib.

For some platforms (tested on Ubuntu 12.04), the Python 2.6 library is no longer available. You may need to find a distribution for yourself for your platform. For Ubuntu users, you may go to Ubuntu Archives. You will then need to extract the files dpkg-deb -x python2.6_2.6.5-1ubuntu6_i386.deb python2.6. Finally, move usr/lib/python2.6 from the extracted files to [Sublime Text 2 Directory]/lib