• jon@schemawound.com

Getting more out of Sublime Text 2

In the past I have posted about my love of Sublime Text 2.  After using it for my Supercollider work for several months I have found a number of plugins and other things to make my work easier.

Install

Before we continue you will need to install Sublime Text 2 and the Supercollider plugin for it:

  • Download and install Sublime Text 2 from http://www.sublimetext.com/2
  • Download the Supercollider package for Sublime Text from (use the zip icon towards the upper left) https://github.com/geoffroymontel/supercollider-package-for-sublime-text
  • Run Sublime Text 2.
  • Go to Preferences / Browse Packages – this will open the location your Sublime Text 2 packages are stored in.
  • Create a directory named Supercollider and put all the files from the plugin you downloaded into it.
  • Open SuperCollider.sublime-settings and change the sc_dir to match the path you installed Supercollider in.  If you used the default install path it is already correct except in Windows 64-bit.  In that case you will need to change the path from “Program Files” to “Program Files (x86)”.
  • You will now have a Supercollider menu under you Tools menu.  Pick start SCLang to start up supercollider.  The console will appear at the bottom of your text window and supercollider will boot .
  • Use Ctrl-Enter to evaluate any line.  If there is an opening or closing parenthesis it will highlight and evaluate the whole block.

SCCode Search

Since the current version of Supercollider help does not work on windows you can use the shortcut of Ctrl+Shift+, instead.  This will search the highlighted text on SCCode.org.

Sidebar

The side bar allows you quick access to your open files as well allowing you to browse frequently used directories:

  • From the menu select View -> Side Bar -> Show Side Bar (or Ctrl-K, Ctrl-B).
  • Drag folders from your windows explorer into the Side Bar in order to pin them there.
  • Click a file to preview it in the current pane.  Double-Click to open it.

Spot Unsaved Changes

  • From the menu select Preferences -> Settings – Default.
  • Find the option “highlight_modified_tabs” and set it to true.  This will cause unsaved changes to be highlighted in a different color.

Package Control

Package Control is a full-featured package manager that helps discovering, installing, updating and removing packages for Sublime Text 2.

In order to install it:

  • Press Ctrl+` (NOT Ctrl+’) to show the Sublime Text console.
  • Copy and paste the following into the console
    import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
  • Restart Sublime Text
  • In order to access Package Control commands press Ctrl-Shift-P and begin typing “package” until the commands are visible
  • Discover Package will bring you to a webpage with a browsable list of packages
  • Install Package will allow you to install with a single click without leaving Sublime Text.  This is the way you will install any plugins referenced later in this post.

Google Search

The plugin google-search allows you to right-click on any highlighted text and select “Google Search” in order to open a search in a new browser window.

HTML Export

The HTML Export plugin allows you export your current file as nicely formatted HTML with embedded Javascript and CSS. 

  • Press Ctrl-Shift-p.
  • Choose HTML Export:Current File.

GoTo Tab

GoTo Tab is a simple plugin for quickly navigating between different tabs.  Press Ctrl+TabNumber (Numbered from left to right) to quickly select the tab you need.

Side Bar Enhancements

Side Bar Enhancements adds a large collection of commands to the right-click menu on your side bar.  This brings the side bar more in line with a true file explorer, allowing you to create and delete file and directories.

WinMerge

I have talked before about how useful WinMerge when you are trying to compare various versions of files.  The WinMerge plugin allows you to quickly launch a copy of WinMerge and compare the last two tabs you have activated in Sublime Text.  To launch it press Ctrl+Alt+D.  It should be noted that you need to have a copy of WinMerge installed and it is only available for Windows.

Bracket Highlighter

Bracket Highlighter is very useful plugin for Supercollider work as it helps in debugging deeply nested brackets.  The plugin performs better bracket highlighting then the standard Sublime Text 2 implementation and also shows symbols in the gutter to help track down what lines contain the start and end of a bracket.

Origami

The final plugin I wanted to mention was Origami.  Origami allows you to take pane management inside of Sublime Text to the next level.  Press Ctrl+K+ArrowKey to create a new pane in that direction.  There are hot keys every aspect of pane management.  I would recommend looking at the documentation on the Origami page.