Skip to content

Instantly share code, notes, and snippets.

@toastdriven
Forked from epicserve/sublime_text_2_notes.md
Created July 29, 2011 16:04
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save toastdriven/1114117 to your computer and use it in GitHub Desktop.
Save toastdriven/1114117 to your computer and use it in GitHub Desktop.
My Sublime Text 2 Setup
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>author</key>
<string>Daniel Lindsley</string>
<key>name</key>
<string>My Twilight</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>
<dict>
<key>background</key>
<string>#1F1F1F</string>
<key>caret</key>
<string>#A7A7A7</string>
<key>foreground</key>
<string>#F8F8F8</string>
<key>invisibles</key>
<string>#FFFFFF40</string>
<key>lineHighlight</key>
<string>#FFFFFF08</string>
<key>selection</key>
<string>#DDF0FF33</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Comment</string>
<key>scope</key>
<string>comment</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#5F5A60</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Constant</string>
<key>scope</key>
<string>constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#CF6A4C</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Entity</string>
<key>scope</key>
<string>entity</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#9B703F</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Keyword</string>
<key>scope</key>
<string>keyword</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#CDA869</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Storage</string>
<key>scope</key>
<string>storage</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#F9EE98</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>String</string>
<key>scope</key>
<string>string</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#8F9D6A</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Support</string>
<key>scope</key>
<string>support</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#9B859D</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Variable</string>
<key>scope</key>
<string>variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#7587A6</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid – Deprecated</string>
<key>scope</key>
<string>invalid.deprecated</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic underline</string>
<key>foreground</key>
<string>#D2A8A1</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Invalid – Illegal</string>
<key>scope</key>
<string>invalid.illegal</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#562D56BF</string>
<key>foreground</key>
<string>#F8F8F8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>-----------------------------------</string>
<key>settings</key>
<dict/>
</dict>
<dict>
<key>name</key>
<string>♦ Embedded Source</string>
<key>scope</key>
<string>text source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#B0B3BA14</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ Embedded Source (Bright)</string>
<key>scope</key>
<string>text.html.ruby source</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#B1B3BA21</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ Entity inherited-class</string>
<key>scope</key>
<string>entity.other.inherited-class</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#9B5C2E</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ String embedded-source</string>
<key>scope</key>
<string>string source</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#DAEFA3</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ String constant</string>
<key>scope</key>
<string>string constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#DDF2A4</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ String.regexp</string>
<key>scope</key>
<string>string.regexp</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#E9C062</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ String.regexp.«special»</string>
<key>scope</key>
<string>string.regexp constant.character.escape, string.regexp source.ruby.embedded, string.regexp string.regexp.arbitrary-repitition</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#CF7D34</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ String variable</string>
<key>scope</key>
<string>string variable</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8A9A95</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ Support.function</string>
<key>scope</key>
<string>support.function</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#DAD085</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>♦ Support.constant</string>
<key>scope</key>
<string>support.constant</string>
<key>settings</key>
<dict>
<key>fontStyle</key>
<string></string>
<key>foreground</key>
<string>#CF6A4C</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>c C/C++ Preprocessor Line</string>
<key>scope</key>
<string>meta.preprocessor.c</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8996A8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>c C/C++ Preprocessor Directive</string>
<key>scope</key>
<string>meta.preprocessor.c keyword</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#AFC4DB</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>✘ Doctype/XML Processing</string>
<key>scope</key>
<string>meta.tag.sgml.doctype, meta.tag.sgml.doctype entity, meta.tag.sgml.doctype string, meta.tag.preprocessor.xml, meta.tag.preprocessor.xml entity, meta.tag.preprocessor.xml string</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#494949</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>✘ Meta.tag.«all»</string>
<key>scope</key>
<string>declaration.tag, declaration.tag entity, meta.tag, meta.tag entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#AC885B</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>✘ Meta.tag.inline</string>
<key>scope</key>
<string>declaration.tag.inline, declaration.tag.inline entity, source entity.name.tag, source entity.other.attribute-name, meta.tag.inline, meta.tag.inline entity</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#E0C589</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css tag-name</string>
<key>scope</key>
<string>meta.selector.css entity.name.tag</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#CDA869</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css:pseudo-class</string>
<key>scope</key>
<string>meta.selector.css entity.other.attribute-name.tag.pseudo-class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8F9D6A</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css#id</string>
<key>scope</key>
<string>meta.selector.css entity.other.attribute-name.id</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8B98AB</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css.class</string>
<key>scope</key>
<string>meta.selector.css entity.other.attribute-name.class</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#9B703F</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css property-name:</string>
<key>scope</key>
<string>support.type.property-name.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#C5AF75</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css property-value;</string>
<key>scope</key>
<string>meta.property-group support.constant.property-value.css, meta.property-value support.constant.property-value.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F9EE98</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css @at-rule</string>
<key>scope</key>
<string>meta.preprocessor.at-rule keyword.control.at-rule</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8693A5</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css additional-constants</string>
<key>scope</key>
<string>meta.property-value support.constant.named-color.css, meta.property-value constant</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#CA7840</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>§ css constructor.argument</string>
<key>scope</key>
<string>meta.constructor.argument.css</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#8F9D6A</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>⎇ diff.header</string>
<key>scope</key>
<string>meta.diff, meta.diff.header, meta.separator</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#0E2231</string>
<key>fontStyle</key>
<string>italic</string>
<key>foreground</key>
<string>#F8F8F8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>⎇ diff.deleted</string>
<key>scope</key>
<string>markup.deleted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#420E09</string>
<key>foreground</key>
<string>#F8F8F8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>⎇ diff.changed</string>
<key>scope</key>
<string>markup.changed</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#4A410D</string>
<key>foreground</key>
<string>#F8F8F8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>⎇ diff.inserted</string>
<key>scope</key>
<string>markup.inserted</string>
<key>settings</key>
<dict>
<key>background</key>
<string>#253B22</string>
<key>foreground</key>
<string>#F8F8F8</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: List</string>
<key>scope</key>
<string>markup.list</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#F9EE98</string>
</dict>
</dict>
<dict>
<key>name</key>
<string>Markup: Heading</string>
<key>scope</key>
<string>markup.heading</string>
<key>settings</key>
<dict>
<key>foreground</key>
<string>#CF6A4C</string>
</dict>
</dict>
</array>
<key>uuid</key>
<string>76FA9F40-12A4-4445-9075-B84AE95B3D6A</string>
</dict>
</plist>
<snippet>
<content><![CDATA[
import pdb; pdb.set_trace()
]]></content>
<tabTrigger>pdb</tabTrigger>
<scope>source.python</scope>
</snippet>
import os
import sublime, sublime_plugin
class PyflakesCommand(sublime_plugin.TextCommand):
def run(self, edit):
if self.view.file_name().endswith('.py'):
file_path = self.view.file_name()
folder_name, file_name = os.path.split(file_path)
self.view.window().run_command('exec', {'cmd': ['/usr/local/share/python/pyflakes', file_path], 'working_dir': folder_name})
sublime.status_message("pyflakes " + file_name)
def is_enabled(self):
return self.view.file_name().endswith('.py')
import os
import subprocess
import tempfile
import sublime, sublime_plugin
class ReformatJsonCommand(sublime_plugin.TextCommand):
def run(self, edit):
the_data = sublime.Region(0, self.view.size())
contents = self.view.substr(the_data)
tmp_low, tmp_name = tempfile.mkstemp()
tmp = open(tmp_name, 'w')
tmp.write(contents)
tmp.close()
proc = subprocess.Popen(['python', '-m', 'json.tool', tmp_name], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = proc.communicate()
if proc.returncode != 0:
sublime.status_message("Failed to reformat JSON.")
panel = self.view.window().get_output_panel("json")
self.view.window().run_command('show_panel', {'panel': 'output.json'})
panel.set_read_only(False)
edit = panel.begin_edit()
panel.insert(edit, 0, stderr)
panel.end_edit(edit)
return
self.view.erase(edit, the_data)
self.view.insert(edit, 0, stdout)
sublime.status_message("JSON reformatted.")

User File Settings

Goes in ~/Library/Application Support/Sublime Text 2/Packages/User/Base File.sublime-settings:

{
    "color_scheme": "Packages/Color Scheme - Default/My Twilight.tmTheme",
    "draw_white_space": "all",
    "font_face": "monofur",
    "font_size": 13,
    "translate_tabs_to_spaces": true,
    "trim_automatic_white_space": true,
    "trim_trailing_white_space_on_save": true,
    "ensure_newline_at_eof_on_save": true,
    "rulers": [80],
    "caret_style": "phase"
}

User Global Settings

Goes in ~/Library/Application Support/Sublime Text 2/Packages/User/Global.sublime-settings:

{
    "folder_exclude_patterns": [".svn", ".git", ".hg", "CVS", ".tox"],
    "new_window_settings":
    {
        "side_bar_visible": false,
        "status_bar_visible": true,
        "show_tabs": true,
        "show_minimap": false
    }
}

User Key Bindings

See included files for these commands:

[
    { "keys": ["ctrl+shift+v"], "command": "pyflakes" },
    { "keys": ["ctrl+shift+h"], "command": "reformat_json" },
    { "keys": ["super+l"], "command": "show_overlay", "args": {"overlay": "goto", "text": ":"} },
    { "keys": ["super+shift+l"], "command": "expand_selection", "args": {"to": "line"} }
]

They are placed in the ~/Library/Application Support/Sublime Text 2/Packages/User folder.

Command Line Helper

At the shell:

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/usr/local/bin/subl

# In ~/.bash_profile...
alias st='subl -n'

Usage:

cd ~/Code/Python/django-tastypie
st .

Packages

  • None

Theme

I use my TM theme, which is a lighter variant on twilight. It's included in this Gist & goes in ~/Library/Application Support/Sublime Text 2/Packages/Color Scheme - Default/My Twilight.tmTheme.

Idioms

  • I don't use fullscreen.
  • Each project gets it's own window, not everything all in one window.
  • I keep the sidebar hidden pretty much all the time & lean on Goto File (Cmd+T).
  • Cmd+R jumps to symbols in the file, like TM's symbol dropdown or Cmd+T (Cmd+Shift+T?).

Struggles

  • Ctrl-G is goto line. (want it to be Cmd+L)
  • Cmd+L is select line. (want it to be Cmd+Shift+L+)

Things TextMate had that I Miss

  • Better variable completion
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment