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

Colorcoder

by vprimachenko ST2/ST3

Semantic highlight for Sublime Text

Details

  • 3 2014.12.23.19.17.54
    2 2014.11.13.15.03.21
  • github.​com
  • github.​com
  • 5 years ago
  • 58 minutes ago
  • 6 years ago

Installs

  • Total 131K
  • Win 88K
  • OS X 24K
  • Linux 19K
Nov 19 Nov 18 Nov 17 Nov 16 Nov 15 Nov 14 Nov 13 Nov 12 Nov 11 Nov 10 Nov 9 Nov 8 Nov 7 Nov 6 Nov 5 Nov 4 Nov 3 Nov 2 Nov 1 Oct 31 Oct 30 Oct 29 Oct 28 Oct 27 Oct 26 Oct 25 Oct 24 Oct 23 Oct 22 Oct 21 Oct 20 Oct 19 Oct 18 Oct 17 Oct 16 Oct 15 Oct 14 Oct 13 Oct 12 Oct 11 Oct 10 Oct 9 Oct 8 Oct 7 Oct 6 Oct 5
Windows 49 54 37 32 64 66 69 62 46 42 30 46 38 47 52 55 26 17 43 54 44 51 59 39 45 49 57 49 40 52 31 29 59 45 44 35 43 35 39 42 40 32 47 45 32 43
OS X 7 4 7 7 15 10 14 7 5 5 6 5 11 12 4 10 3 5 7 8 3 7 7 2 2 2 5 5 3 5 4 4 9 6 6 8 9 8 5 11 3 5 6 6 1 4
Linux 6 8 6 4 9 18 12 6 6 6 4 3 8 8 4 6 3 6 8 9 6 16 5 4 4 16 6 7 3 5 7 8 3 7 6 5 4 5 5 9 11 1 3 4 4 6

Readme

Source
raw.​githubusercontent.​com

Colorcoder

This plugin for Sublime Text will highlight every variable in its own, consistent color — feature known as semantic highlighting, variable-name highlighting, contextual highlighting — you name it.

Notice how all instances of m_nValue share the same color

Motivation

  • “Coding in color” by Evan Brooks
  • actually thought about something to improve the current highlighting system and accent the data flow
  • help dysgraphic/dyslexic coder

it is important to note i use a crc8 hash of the variable name to give similar named variables distinct colors to improve typo recognition

Installation

Download the zip-ball and unpack to sublime\data\packages or via packageControl. Please make sure to name the resulting folder Colorcoder not Sublime-Colorcoder.

To properly work Colorcoder needs an appropriately modified color scheme. On the first run plugin will try its best to automatically modify your current scheme. :grey_exclamation: the plugin will not actually modify the scheme but create a modified copy in its own directory and apply it. You can use ToolsPackagesColorcoderTweak Colorcode on current color scheme (or CTRLSHIFTP it) to modify the colors a bit (you can change the lightness and saturation). Colorcoder also needs a “good” language definition, which it does not activate automatically but leaves you the choice to do so, read below for more.

Supported Languages

As the few language definitions provided by Sublime are insufficient for optimal Colorcoder results I bundle tailored definitions. So far it's

  • C++
  • Python
  • Lua
  • Go
  • Ruby
  • CoffeeScript (via by @aponxi)

for JavaScript please use the JavaScript Next package.

You can set them up as default via language menuOpen all with current extension asColorcoder… (Colorcoded) or copy them to appropriate folder (erg. Packages/Colorcoder/Python (Colorcoded).tmLanguage to Packages/Python/Python.tmLanguage.

You can also add more scopes for the plugin to colorize via the scopes setting. Colorcoder comes with a handy command colorcoder_inspect_scope which will print the scope of the token under text cursor to the console. You can bind it to a key (e.g. CTRLF12) by adding following to PreferencesKey Bindings – User

{ "keys": ["ctrl+f12"], "command": "colorcoder_inspect_scope"},

Sometimes things we are interested in don't have distinct scope e.g. the variables in Javascript are only source.js. You would need to modify the .tmLanguage.

  • First you need to obtain it - it is inside the same names .sublime-package file, which is a zip-archive
  • now locate the first instance of

    <key>patterns</key>
    <array>
    

it should be somewhere within the first 50–100 lines - use code folding to find where according </array> is - place following right before it

<dict>
        <key>comment</key>
        <string>colorize everything</string>
        <key>match</key>
        <string>\b\w+\b</string>
        <key>name</key>
        <string>colorize</string>
    </dict>

or modify the bundled .tmLanguage files, you probably would only need to replace the keywords

Options

You can turn the highlighting off per view via ViewColorcode this view. Colorcoder also might slow down the editor when highlighting huge files, so it will turn itself off once the file has exceeded the max_size (the check happens when you save the file or reactivate the view). You can force it to highlight the file nevertheless via said menu item (which will read Colorcoding may hurt performance, File is large now) Default (faster) highlighting method makes the undo work letterwise, you can change this by setting use_fast_highlighting_but_undo_typing_letterwise to false. Colorcoder will then use alternative engine, which does not interfer with undo, but work somewhat slower on large files. You might want to tune max_size lower then. Colorcoder allows you to specify white- and blacklist for file-types to highlight: the settings are enabled_for and disabled_for. If enabled_for is present in the config only those file-types will be highlighted, disabled_for won't be highlighted even if present in whitelist. Finally :exclamation: if you use some plugins which change the color scheme based on time, or filename, or modify the schemes you better turn the auto_apply_on_scheme_change off, or the plugin conflict may result in an endless loop which will lock the editor. You can always change the settings even when sublime is not running.

Contact

You can reach me via email: vprimachenko@ya.ru, twitter: @vprimachenko or visit the official irc channel freenode.net#colorcoder (webchat). If Colorcoder was usefull to you i greatly appreciate a donation via Bitcoin 1DzZ1thGTHubRzoxEeDCJnJZwgFpna6jQk.