Skip to content

Instantly share code, notes, and snippets.

@phlco
Last active December 18, 2015 14:08
Show Gist options
  • Save phlco/5794605 to your computer and use it in GitHub Desktop.
Save phlco/5794605 to your computer and use it in GitHub Desktop.
sublime text notes

Sublime

There are three resources for documentation on Sublime Text 2:

A full-featured package manager that helps discovering, installing, updating and removing packages for Sublime Text 2.

Installation is through the Sublime Text 2 console. This is accessed in Sublime via the ctrl+` shortcut. Once open, paste the following command into the console:

import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print('Please restart Sublime Text to finish installation')

Hit Enter then restart Sublime for the changes to take affect.

The Command Palette

Use command+Shift+P to bring up the Command Palette. From there type Install to search for the Package Control: Install command then press Enter. This will list available packages to install. Just type in a package name to find it and hit Enter to install.

Here are some good packages to start out with:

  • SideBarEnhancements Adds additional commands(reveal, duplicate, new file etc) to the context menu in the sidebar.

  • Sublime Linter Highlights lines of code with potential errors

  • dotfiles-syntax-highlighting-st2 Syntax Highlighting for dot files.

  • Gist Create and edit gists

Sublime Text 2 includes a command line tool, subl, to work with files on the command line. This can be used to open files and projects in Sublime Text 2, as well working as an EDITOR for unix tools, such as git and subversion.

From the terminal enter the following:

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

Now we can use subl . (to open the entire current directory) or sublime filename to open a file.

Sublime Preferences

command+, will open Sublime User Preferences. User Preferences are defined in JSON. You can override system settings here. Check Preferences > Settings - Default for a full list. Here are some suggested User Preferences.

    {
        "auto_complete": true,
        "auto_complete_commit_on_tab": true,
        "auto_match_enabled": true,
        "close_windows_when_empty": true,
        "color_scheme": "Packages/Color Scheme - Default/Solarized (Dark).tmTheme",
        "default_line_ending": "LF",
        "detect_indentation": true,
        "dictionary": "Packages/Language - English/en_US.dic",
        "draw_white_space": "all",
        "fade_fold_buttons": true,
        "file_exclude_patterns":
        [
            "*.a",
            "*.class",
            "*.db",
            "*.dll",
            "*.dylib",
            "*.exe",
            "*.idb",
            "*.lib",
            "*.log",
            "*.ncb",
            "*.o",
            "*.obj",
            "*.pdb",
            "*.pdf",
            "*.psd",
            "*.pyc",
            "*.pyo",
            "*.sdf",
            "*.so",
            "*.suo",
            ".DS_Store",
            ".tag"
        ],
        "folder_exclude_patterns":
        [
            ".bundle",
            ".git",
            ".hg",
            ".rbx",
            ".sass-cache",
            ".svn",
            "bin",
            "bundle",
            "CVS",
            "data",
            "script",
            "tmp"
        ],
        "highlight_line": true,
        "hot_exit": false,
        "ignored_packages":
        [
            "Vintage"
        ],
        "rulers":
        [
            80
        ],
        "scroll_past_end": true,
        "soda_classic_tabs": true,
        "spell_check": false,
        "tab_size": 2,
        "translate_tabs_to_spaces": true,
        "theme": "Soda Light.sublime-theme",
        "trim_trailing_white_space_on_save": true
    }

Fonts

It's best to work with mono spaced fonts. Adobe's Source Code Pro is a good one you can download from Source Forge.

To install, first open Font Book on your Mac. Then unzip the Source Code Pro file and locate the OTF folder inside. Drag the OTF folder into Font Book.

To set as the default font in Sublime just add "font_face": "SourceCodePro-Regular" to your User Preferences.

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