This web site has been retired. Please follow my activities at pztrick.com.

pZtrick.com

the personal site of patrick paul

Patrick's Sublime Text Reference

This page documents my very scandalous love affair with Sublime Text 2.

Cross-platform Installation & Settings

Windows #

Download the installer here.

Ubuntu (with PPA Repository) #

linux bash #
1
2
3
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text

Dropbox & Symbolic Links #

Basically, you replace the settings folders in the relevant AppData or .config folders with symbolic links to duplicates you’ve placed in your Dropbox. This allows your packages and settings to persist across machines.

bash terminal (install dropbox) #
1
2
3
sudo apt-key adv --keyserver pgp.mit.edu --recv-keys 5044912E
sudo add-apt-repository "deb http://linux.dropbox.com/ubuntu $(lsb_release -sc) main"
sudo apt-get update && sudo apt-get install nautilus-dropbox
linux bash #
1
2
3
ln -s ~/Dropbox/settings/sublime-text-2/Packages ./Packages
ln -s ~/Dropbox/settings/sublime-text-2/Installed\ Packages ./Installed\ Packages
ln -s ~/Dropbox/settings/sublime-text-2/Pristine\ Packages ./Pristine\ Packages
windows cmd #
1
2
3
mklink /D "Installed Packages" "C:\path\to\Dropbox\settings\sublime-text-2\Installed Packages"
mklink /D "Packages" "C:\path\to\Dropbox\settings\sublime-text-2\Packages"
mklink /D "Pristine Packages" "C:\path\to\Dropbox\settings\sublime-text-2\Pristine Packages"

Symbiotic Ubuntu Packages

These are the other development tools I use in conjunction with Sublime Text 2, and which I have tailored my selection of Sublime Text plugins to.

  • git
  • virtualenv & virtualenvwrapper
  • rvm
  • autoenv

Workflow & Project Settings #

ST2 Hotkeys

This is a reference to all the vanilla Sublime Text 2 hotkeys that I use all the time.

  • Ctrl ` – Python console pane (Sublime Text virtualenv)
  • Ctrl Shift P – Command palette
  • Ctrl Alt P – Switch Project
  • Ctrl P – Go To Anything (navigates between files)
  • Ctrl G – Go To Line
  • Ctrl F – Find
  • Ctrl H – Replace
  • F11 – Fullscreen
  • Shift F11 – Distraction Free Mode (Fullscreen)
  • F6 – Spell check
  • Ctrl / – Toggle comment on selected line(s)
  • Ctrl Shift [ – Fold selected text or fold block outside cursor
  • Ctrl Shift ] – Unfold selected block
  • Ctrl K then Ctrl # – Fold code where block-level is equal to #
  • Ctrl K then Ctrl J – Unfold all
  • Ctrl L – Select line
  • Ctrl D – Select word, select multiple occurrences of selected word
  • Ctrl Shift M – Select all within brackets
  • Ctrl Shift J – Select all within block
  • Ctrl Shift Space – Select next higher scope

Custom ST2 Hotkeys

And this is a recent copy of my custom Key Settings file. This file can be selected from the Preferences menu.

Key Bindings - User (json)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[
  { "keys": ["ctrl+shift+alt+z"], "command": "open_terminal" },
  { "keys": ["ctrl+shift+z"], "command": "open_terminal_project_folder" },

  { "keys": ["ctrl+1"], "command": "fold_by_level", "args": {"level": 1} },
  { "keys": ["ctrl+2"], "command": "fold_by_level", "args": {"level": 2} },
  { "keys": ["ctrl+3"], "command": "fold_by_level", "args": {"level": 3} },
  { "keys": ["ctrl+4"], "command": "fold_by_level", "args": {"level": 4} },
  { "keys": ["ctrl+5"], "command": "fold_by_level", "args": {"level": 5} },
  { "keys": ["ctrl+6"], "command": "fold_by_level", "args": {"level": 6} },
  { "keys": ["ctrl+7"], "command": "fold_by_level", "args": {"level": 7} },
  { "keys": ["ctrl+8"], "command": "fold_by_level", "args": {"level": 8} },
  { "keys": ["ctrl+9"], "command": "fold_by_level", "args": {"level": 9} },
  { "keys": ["ctrl+0"], "command": "unfold_all" },
  { "keys": ["ctrl+j"], "command": "unfold_all" }
]

I didn’t like having to hit Ctrl K and Ctrl # in sequence in order to fold code, so I removed the first key combination. And Ctrl J also unfolds everything.

ST2 Plugins & Their Hotkeys

Package Manager #

This is a must-have and should be installed before proceeding. Most packages listed below can be installed using the ST2 command palette after installing Package Manager.

BufferScroll

Buffer Scroll is a simple Sublime Text plug-in which remembers and restores the scroll, cursor positions, also the selections, marks, bookmarks, foldings, selected syntax and optionally the color scheme.

This plugin is a great enhancement to ST2 and doesn’t require any commands to invoke anything. It just recalls your previous session each time you re-open ST2.

Clipboard History

  • Ctrl Alt V (Windows & Linux) – View clipboard history
  • Ctrl Super Alt V (OS X) – View clipboard history

Djaneiro #

Djaneiro provides a set of snippets and auto-completions for various Django templates and models. They can be viewed here.

Git #

This Git plugin provides access to many git commands via the ST2 control pallet (Ctrl Shift P). A full list of what is supported can be viewed in the plugin’s wiki.

I personally do not use the plugin to handle commits (I prefer bash), but the diff, gui launcher, graph, toggle annotations, branch, and log features are excellent.

Per the wiki, another enhancement is to add annotation coloring to your particular theme file.

ImageMagick

This plugin merely shows the dimensions for image files in the status bar. No commands.

Requires sudo apt-get install imagemagick.

KeyMapManager

  • Ctrl Alt K – KeyMap Manager

octopress-sublime-snippets #

  • oc – insert image
  • obq – insert blockquote
  • oc – insert code block

Sass

This adds Sass syntax highlighting. You may need to navigate to navigate the menu to View > Syntax > Open all with current extension as... > Sass in order for it to start working for your particular file extension.

SideBarEnhancements

This plugin adds a lot of neat commands to the right-click context menu upon clicking items in the side pane.

Side Bar Git

This plugin adds a Git context menu to the right-click menu on the side pane.

SmartMarkdown #

SmartMarkdown adds tab code folding to Markdown documents which collapses headings.

  • Tab – Collapse/un-collapse selected Markdown heading (## Heading 2, ### Heading 3, etc.)
  • Shift Tab – Collapse/un-collapse all Markdown headings

It has also integrated the SublimePandoc package which adds these excellent Command Palette commands:

  • Pandoc: Render Markdown to DocX
  • Pandoc: Render Markdown to HTML
  • Pandoc: Render Markdown to PDF
  • Pandoc: Render Markdown to temp HTML and View
  • Pandoc: Render Markdown to temp PDF and View

The Pandoc integration requires these Ubuntu packages: pandoc texlive-latex-base texlive-latex-recommended.

sublime-github #

This plugin provides additional Command Palette functions for browsing and updating gists.

SublimeLinter

Provides source code checking and Python PEP8 style guide validation. Python is natively supported, but other languages may require external lint packages to be installed. It runs in the background by default, but can be configured to run via the Command Palette instead.

SublimeREPL

This adds various REPL (read-eval-print loop) consoles to the Command Palette which open in a new tab within Sublime. Most interpreted programming languages appear to be supported. Some sample Palette commands:

  • SublimeREPL: Python (system python environment)
  • SublimeREPL: Sublime Python (sublime python environment)
  • SublimeREPL: Python - RUN current file
  • SublimeREPL: Python - PDB current file
  • SublimeREPL: Shell
  • SublimeREPL: Ruby
  • SublimeREPL: Clojure
  • SublimeREPL: R

SublimeRope #

Adds Python code completions which can be invoked as-you-type or via Ctrl Space. It is smart and seeks out all installed Python libraries and adds those classes to its auto-complete functionality.

In order to use with virtualenv, you’ll want to create a Rope project in your workspace using the Command Palette and then modify the config.py file as follows:

config.py
1
prefs.add('python_path', '/home/patrick/virtualenvs/VENV_NAME_HERE/lib/python2.7/site-packages')

Once you’ve done that, it’ll know where to look for all your vitualenv’s Python libraries and will add those modules to its code completions magic.

Here are all the Code Palette tools:

  • Rope: New project
  • Rope: Show documentation – Shows the required arguments and doc-string for the selected function
  • Rope: Go To Definition – Navigates to the line where selected variable was definied
  • Rope: Jump To Global – Similar to Go To Definition. Provides a list of global variables for you to select and then navigate to.
  • Rope: Regenerate Project Cache
  • Rope: Regenerate Global Module Cache
  • Rope: Import Assist
  • Rope Refactoring: Rename
  • Rope Refactoring: Restructure
  • Rope Refactoring: Extract Method
  • Rope Refactoring: Extract Variable
  • Rope Refactoring: Inline Variable

SublimeTODO #

This plugin parses open & project files for TODO or FIXME comments (or other user-defined patterns) and outputs them to a new tab for display. I frequently stick TODO comments into Python projects so this is a great solution for managing all my to-do items.

  • Show TODOs: Open files only
  • Show TODOs: Project and open files

Terminal

  • Ctrl Shift Z – Terminal at project folder (modified via User settings file)
  • Ctrl Alt Shift Z – Terminal at current file location (modified via User settings)

Theme - Soda #

Just a great visual theme for the Sublime Text GUI.

Color Scheme - Chubby-er Ninja #

ST2 ships with a dozen or so perfectly useable color schemes, but I found one I liked better on GitHub called Chuby Ninja. I’ve made a few customizations and am titling my version Chubby-er Ninja.

I keep track of it in this gist:


Extendability

Clearly, Sublime Text 2 is a very extendable text editor. I will try to follow best practices when hacking my plug-ins by modifying Users settings files (instead of Defaults) and by forking git repositories for the plugin whereever possible. I expect to be tweaking a lot of the plugins myself as they are mostly/all written in Python.

Comments