My Sublime Text Config

on December 05, 2014 17:00

Read this article listening to: 'Sublime - Santeria' (I had to put up 4 years with my former boss singing that) =P

DISCLAIMER 1: I won't get into the battle 'What is the ideal IDE/text editor?'. I use Sublime Text, I'm happy with it, so get over it.

DISCLAIMER 2: These tips apply to Sublime Text only. Some of them apply only to OS X. I'm sure you can find a way on other systems.

Sublime Text is my favorite text editor and the one I use everyday. It is a great piece of software, I make money from it, and it is just fair that the developer gets something in return. Register it!

Sublime can be highly customizable, and it takes some time to perfect it to one's needs. I've been using it for a few years, so I'm sharing my configuration so everyone can benefit from it.

First things first: I really, really, REALLY hate that logo. It's orange on gray, it is 3D, anyway, I don't like it at all. So I replaced it for a more comforting one.

My Sublime Text Logo

How to replace the logo

Get a nice logo from the internetz (this is a great one) and download the .icns file. Then, open up the Applications folder in Finder, right-click 'Sublime Text' and select 'Show Package Contents'; open 'Contents -> Resources' and replace your Sublime Text.ics file there.

Shell symlink

$ sudo ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" /bin/subl

for OS X. Adjust the path if you're using GNU/Linux.

Then you can use it to open your current directory:

$ subl .

Package Control

If you don't use it, go ahead and install it! Inside Sublime Text, type

ctrl-`

and paste the following code (don't worry, it's safe).

import urllib.request,os,hashlib; h = '7183a2d3e96f11eeadd761d777e62404' + 'e330c659d4bb41d3bdf022e94cab3cd0'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

Packages

Use super + shift + P and type 'Install package' to bring the package list.

General usage

  • Advanced New File: creates new files with a better interface
  • DashDoc: searches documentation in Dash
  • Emmet: creates HTML elements
  • GitGutter: marks changes in files
  • Prefixr: adds prefixes for browsers in CSS files
  • Markdown Preview
  • SidebarEnhancements: adds a lot of options when you right-click the sidebar
  • TrailingSpaces: shows trailing spaces in bright red

Language/syntax specific

  • AngularJS
  • HTML5
  • Puppet
  • RSpec
  • SCSS
  • SublimeERB: adds a shortcut for <%= %> (see below)
  • Vagrant

Code linter

Sublime Linter package with the following linters:

  • annotations
  • csslint
  • jshint
  • json
  • ruby

Note: you may run into some problems due to linter executable location. You might have to change your PATH environment variable a bit.

Preferences

This is my user preferences file. You can take this as a start for yours. I'm using Cobalt 2 theme, so you should change it to yours.

{
  "auto_complete_commit_on_tab": true,
  "bold_folder_labels": true,
  "color_scheme": "Packages/User/Color Highlighter/themes/cobalt2 (SL).tmTheme",
  "draw_white_space": "all",
  "file_exclude_patterns":
  [
    ".DS_Store",
    ".tags*",
    "*.pyc",
    "*.pyo",
    "*.exe",
    "*.dll",
    "*.obj",
    "*.o",
    "*.a",
    "*.lib",
    "*.log",
    "*.so",
    "*.dylib",
    "*.ncb",
    "*.sdf",
    "*.suo",
    "*.pdb",
    "*.idb",
    "*.class",
    "*.psd",
    "*.db",
    "*.pdf"
  ],
  "folder_exclude_patterns":
  [
    "data",
    ".git",
    ".svn",
    ".hg",
    "CVS",
    ".sass-cache",
    ".bundle",
    "bundle",
    ".rbx",
    "tmp",
    ".tmp",
    "htdocs"
  ],
  "font_face": "Monaco",
  "font_size": 18.0,
  "highlight_line": true,
  "highlight_modified_tabs": true,
  "ignored_packages":
  [
    "AdvancedNewFile",
    "Gutter Color",
    "Vintage"
  ],
  "tab_size": 2,
  "theme": "Cobalt2.sublime-theme",
  "translate_tabs_to_spaces": true,
  "trim_trailing_white_space_on_save": true,
  "use_tab_stops": true,
  "word_wrap": true
}

Keybindings

  // ERB - prints <%=  %>
  { "keys": ["ctrl+shift+."], "command": "erb" },

  // Reveals the current file in sidebar
  { "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" },

Your turn

Do you use Sublime Text and want to share your tips, suggest packages, share alternate icons? Use the comments!

References

comments powered by Disqus