My SublimeText2 workflow

The editor is perhaps the most important part of the developers toolchain. As such, it is a field of tremendous amounts of contention. One of the most legendary flamewars of all time, the constant vim-vs-emacs debate, is an example of this.

Many people have been looking to SublimeText2 as their editor of choice, and I am no exception. I've been using it for over a year and a half now, and offer these tips to anyone looking to switch editors, or just improve their knowledge of ST2.

Configuration

One of the best parts of SublimeText2 is how configurable it is. You can shape it into whatever editor you want, instead of having to comply to predefined conventions, like most IDEs force you into.

I recommend reading through both the Default and User configuration files. The default config is very well documented, and should give you an idea about configuring your editor. But don't edit the default file. If you want to change a setting, copy its key-value pair over to your user config. This way, even if ST2 updates and changes a default, your settings will persist.

My user settings file is as follows:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
{
  "auto_complete_commit_on_tab": true,
  "bold_folder_labels": true,
  "caret_style": "smooth",
  "color_scheme": "Packages/TextMate-Tomorrow-Theme/Tomorrow-Night.tmTheme",
  "detect_slow_plugins": false,
  "ensure_newline_at_eof_on_save": true,
  "fallback_encoding": "UTF-8",
  "font_face": "Menlo",
  "font_size": 12.0,
  "highlight_line": true,
  "ignored_packages":
  [
    "Vintage"
  ],
  "indent_guide_options":
  [
    "draw_active"
  ],
  "save_on_focus_lost": true,
  "tab_size": 2,
  "theme": "Soda Dark.sublime-theme",
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true,
  "use_simple_full_screen": true,
  "word_separators": "./\\()\"'-:,.;<>~!@#$%^&*|+=[]{}`~?_"
}

Each setting is as follows:

  • auto_complete_commit_on_tab: This setting sets sublimetext2's excellent autocomplete to trigger on tab. This lets you tap tab twice to select the default completion, and removes ambiguity about what the enter key will do.
  • bold_folder_labels: Fairly straightforward. This makes folder labels in the sidebar bold. While not as good as the folder icons in some other editors (TextMate2), this is a nice minimalist way to see the differences between files and folders.
  • caret_style: I set mine to smooth because I like the way it looks. This one is purely cosmetic
  • color_scheme: I'm using a custom fork of the tomorrow-night theme, because I like how it looks.
  • detect_slow_plugins: ST2 is very sensitive about slow plugins, and likes to whine about them a lot. You may not notice a slowdown, but ST2 will pop up a big, workflow-interrupting dialog box preaching of doom and gloom regarding a slow plugin. I found its better to disable this alert.
  • ensure_newline_at_eof_on_save: This is something that enforces good code practice. Git and other tools tend to whine if you don't have one, and it makes it easier to see the file termination, as well as add to the end of an existing file. This saves you the trouble.
  • fallback_encoding: I set this to UTF-8 so that, in the event the editor couldn't detect the setting, I go to Unicode.
  • font_face: Apple's Menlo font is quite readable, and works well as a fixed width font. It is based off of the Bitstream fonts, and supports bold and italic glyphs.
  • font_size: self-explanatory
  • highlight_line: colors the current line, according to the the theme. This is useful when you're looking at a large amount of code and need to find your place in the document
  • ignored_packages: I don't use the vintage package, so I have it disabled. This is cleaner than plain uninstalling it, although for user-installed packages, you probably just want to uninstall them
  • indent_guide_options: ST2 has quite a few options to show indent guides. I find showing them all the time tends to get somewhat distracting, so I have mine set to show them only for the current scope.
  • save_on_focus_lost: Make sure you never lose the document's latest changes. Also very good for web development with live reload plugins, as you can see your changes manifest themselves in real time.
  • tab_size: 2 spaces for life
  • theme: I use the SodaStyle Dark theme because I like the way it looks, and how it integrates into my color scheme. Its icons are typically more polished than the stock icons. If you like a light UI, similar to XCode, you might want to try SodaStyle Light.
  • translate_tabs_to_spaces: If you get a document from someone who is stuck in the 80s and still uses tabs, this will make it so you can deal with their documents in a sane manner.
  • trim_trailing_white_space_on_save: This isn't the full solution to this problem, but it helps. Basically, this attempts to remove all excess whitespace on save. Combine this with the similarly named package and you've got a nice solution to cut down on unneeded characters
  • use_simple_full_screen: This is primary of concern for OS X Lion and up users, because this tells ST2 to use the old-style fullscreen, which is more compatible with multiple monitor setups
  • word_separators: I customized my word separators, adding a few other characters, such as underscores, to allow for easier completion and navigation in function names. This is particularly useful when dealing with variable names

What about key bindings?

I like the default sublimtext keybindings, but have a few customized ones, mainly related to packages. These are things that are very personalized, and I think that, should you find you don't like the default bindings, feel free to customize them. SublimteText2 keybindings are very easy to customize—like settings, they are a json file, and adopt the “Default” and “User” convention.

Packages

I have a very large number of packages installed, and there really is no penalty to them, but I don't have the time, and I doubt you have the interest, to go through all of them, so I'll list all of mine, and then go into details about a few of them:

I also have some custom ones:

Details

AdvancedNewFile

This package is excellent, as it allows you to very easily create new files, anywhere on the file system. This is significantly faster than having to open a buffer, write your file, then save and chose the location.

Gist

If you share a lot of code with people, this is an excellent plugin. It supports accounts, and allows you to create, update, and delete gists, all from within sublimetext.

Git

Adds git support, which makes it very easy to maintain a git-oriented workflow, and also reduces disruptions as you switch back and forth between editor and a terminal

GitGutter

This is a very IDE-style plugin, but its a feature I find welcome. What it does is put symbols in the gutter that symbolize changes to a file in git. If you have used an IDE like IntelliJ, Rubymine, or Eclipse before, you will have seen this before and certainly know how useful it is.

MarkAndMove

This makes dealing with multiple selections much easier. Instead of having to hold a modifier key down as you move through the document and make selections, you can press a keyboard shortcut to leave a marker at locations. Once you have all the locations you want marked, you can then turn every mark into one big multiple selection. Very useful for dealing with complex selections

Origami

Many people have complained that the way ST2 handles splits isn't the most intuitive. This solves it. It allows you to modify splits in any way you may chose, and easily send files between splits, all without having to leave the keyboard

SidebarEnhancements

These make the sidebar much more useful, allowing you to preform file management tasks, rename files, and much more. Couple this with sidebar git, and you have a nice workflow for dealing with multiple files from within ST2, reducing distractions

SmartMarkdown

If you find yourself writing larger markdown documents, such as this blogpost, then you will welcome this plugin. It adds smarter highlighting for headings, italics, bolds, etc, as well as automatic list continuations and other nice features.

SublimeCodeIntel

I'm still divided on the true use of this package. There is a long-standing ruby bug that prevents it from accurately reflecting which gems you have installed, which makes things like the supposed require auto complete less than useful, but generally I have found the enhancements it offers worth it, particularly when working with larger files, such as monolithic SASS/SCSS files

Theme - Soda

This excellent theme comes in dark and light variants, and should really be the default in ST2. If you want to make it look more like OS X, I'd go with the light variant of this theme and a light color style. I like to go with dark colors and the dark version of this theme.