User Tools

Site Tools


mac:sublime

Sublime Text 3

Sublime Text is an excellent text editor, available for Mac OS X, Windows, and GNU/Linux. It's the spiritual successor to TextMate, and has good (and growing) mind-share.

Sublime Text is commercial software ($70) but a free trial version is available.

We've moved to Sublime Text 3, even though it's still in Beta.

Installation

brew cask install sublime-text-3
 
# Make sure we can start Sublime Text from the command line.
ln -sf '/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl' /usr/local/bin/subl
 
# Add a custom icon for the app.
curl 'http://www.sublimetext.com/forum/download/file.php?id=200' -o 'Sublime Text 2.icns.zip'
unzip 'Sublime Text 2.icns.zip' 'Sublime Text 2.icns'
sips -i 'Sublime Text 2.icns'
DeRez -only icns 'Sublime Text 2.icns' > 'Sublime Text.rsrc'
touch $'/Applications/Sublime Text.app/Icon\r'
Rez -append 'Sublime Text.rsrc' -o $'/Applications/Sublime Text.app/Icon\r'
SetFile -a V $'/Applications/Sublime Text.app/Icon\r'
SetFile -a C '/Applications/Sublime Text.app'
rm 'Sublime Text 2.icns.zip' 'Sublime Text 2.icns' 'Sublime Text.rsrc'
 
# Create a dock icon.
dockutil --add '/Applications/Sublime Text.app'
 
# Install the Package Control package.
mkdir -p "$HOME/Library/Application Support/Sublime Text 3/Installed Packages"
curl -O https://sublime.wbond.net/Package%20Control.sublime-package -o "~/Library/Application Support/Sublime Text 3/Installed Packages/Package Control.sublime-package"

Add-On Packages

See http://wbond.net/sublime_packages/community for a full list of available packages.

Here's how to add a package: Hit Command + Shift + P to open the command palette. Type (partially) Package Control: Install Package and hit Enter. Type (partially) the name of the package, or scroll through the list. Hit Enter when you've found the package you want. Some packages may take a while to download and install. Many packages will open a new buffer with a README when they're done installing. They'll generally also add a menu item to Preferences / Package Settings. Restart Sublime Text to be able to use the plugin.

We generally like to have the following packages installed:

  • Package Control
  • SideBarEnhancements
  • SFTP
  • Theme - Soda
  • GitGutter (adds colored indicators in the gutter for lines that have been added or changed)
  • Alignment
  • SublimeCodeIntel
  • Status Bar Extension

TODO

  • Anypreter
  • Apidock
  • BeautifyRuby
  • Capybara Snippets
  • Additional PHP Snippets
  • AdvancedNewFile
  • All Autocomplete
  • Alternative Autocomplete
  • AndyJS
  • AndyPHP
  • AndyPython
  • AngularJS (CoffeeScript)
  • AutoFileName
  • AutoPEP8
  • ChangeQuotes

Configuration

Theme

Preferences / Settings - User, add:

    "theme": "Soda Light.sublime-theme"

Whitespace

By definition, all lines in a text file must end with a newline character. (See the POSIX definitions of Text File and Line.) We can ensure that by adding this to Preferences.sublime-settings. We also trim whitespace from the ends of lines on save.

    "ensure_newline_at_eof_on_save": true,
    "trim_trailing_white_space_on_save": true,

Appearance

    "bold_folder_labels": true,
    "fade_fold_buttons": false,
    "highlight_line": true,
    "scroll_past_end": true,
    "font_size": 15.0,
    "dictionary": "Packages/Language - English/en_US.dic",
    "caret_extra_width": 2,

Key Bindings

We want to remap a few key bindings. These are under Preferences / Key Bindings - User.

We want to change Control+Tab to cycle through tabs in the order they appear, instead of the order in which they were last accessed. We also want to Control+PageUp and Control+PageDown to cycle through tabs in the same way.

[
    { "keys": ["ctrl+tab"], "command": "next_view" },
    { "keys": ["ctrl+shift+tab"], "command": "prev_view" },
    { "keys": ["ctrl+pagedown"], "command": "next_view" },
    { "keys": ["ctrl+pageup"], "command": "prev_view" }
]

TODO

  • Pick a color scheme:
    • Light:
      • Solarized Light
      • 2morrow
      • clouds
    • Dark:
      • Tubster
      • Railscasts
      • Oceanic Muted
      • Ruby Blue
      • Black Pearl
      • 2morrow Night - Bright
      • Monokai Dark
      • Neon
      • Bespin
      • Cobalt
      • Darkside

TODO

  • Can we programmatically install the license?
  • Can we programmatically install plugins?
    • Yes, but we'd like to do it with Package Control instead of git.

Credits

mac/sublime.txt · Last modified: 2014/04/26 14:16 by Craig Buchek