Skip to content

Instantly share code, notes, and snippets.

@JoshuaJBerk
Last active August 29, 2015 14:01
Show Gist options
  • Save JoshuaJBerk/64c582017052d5b76a42 to your computer and use it in GitHub Desktop.
Save JoshuaJBerk/64c582017052d5b76a42 to your computer and use it in GitHub Desktop.
Settings, Packages, and miscellanea for Sublime Text 3

Sublime Text 3 Setup

Install Package Control

Install Package Control for easy package management.

  1. Open the console with Ctrl+`
  2. Paste in the following:
import urllib.request,os; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); open(os.path.join(ipp, pf), 'wb').write(urllib.request.urlopen( 'http://sublime.wbond.net/' + pf.replace(' ','%20')).read())

From here on out, use Package Control to install everything. +Shift+P, then type Install to get a list of installable packages you can livesearch through. Watch the Status Bar for installation progress.

Add Some Useful Packages

All installed with Package Manager. +Shift+P and type install. Then start typing the name of the extension you want to install.

General

  • SideBarEnhancements Provides enhancements to the operations on Sidebar of Files and Folders.
  • SublimeCodeIntel - Full-featured code intelligence and smart autocomplete engine.
  • DocBlockr - Simplifies writing DocBlock comments in Javascript, PHP, CoffeeScript, Actionscript, C & C++.

HTML, CSS & JS

  • Emmet - (Formerly Zen Coding) For lightning fast coding.
  • SublimeLinter - Code linting & hinting for HTML/CSS/JS.
  • HTMLPrettify - HTML/CSS/JS/JSON code formatter via node.js

Git

  • GitGutter tracks line changes in the gutter.
  • Gist makes gist generation/editing easier.

Settings - User

Accessible via: SublimeTextPreferencesSettings – User, or with +`,'.'

This is a JSON file of custom user configuration settings. Kept in alphabetical order for easy reference.

Note: As a JSON file no comments can be included. Any you add will be stripped out on saving.

{
	"auto_complete": true,
	"auto_complete_commit_on_tab": true,
	"auto_complete_with_fields": true,
	"bold_folder_labels": false,
	"color_scheme": "Packages/User/Monokai (SL).tmTheme",
	"default_encoding": "UTF-8",
	"detect_indentation": true,
	"folder_exclude_patterns":
	[
		".git",
		".bundle",
		".sass-cahe"
	],
	"font_face": "Menlo",
	"font_options":
	[
		"subpixel_antialias"
	],
	"font_size": 12.0,
	"highlight_line": true,
	"highlight_modified_tabs": true,
	"ignored_packages":
	[
	],
	"vintage_start_in_command_mode": true,
	"line_padding_bottom": 1,
	"line_padding_top": 1,
	"tab_size": 4,
	"translate_tabs_to_spaces": true,
	"trim_trailing_white_space_on_save": true,
	"word_wrap": true
}

A complete list of Settings can be referenced in SublimeTextPreferencesSettings – Default.

Override any which aren't to your taste.

Key Bindings - User

Accessible via: SublimeTextPreferencesKey Bindings – User.

Key bindings are the productivity engine which allow you to become one with your text editor. I try to stick with all the defaults to make for an easy install and less chance of potential future clashes. The following are a few small edits I make along with some package specific controls:

[
    // Reveal the currently open file in the sidebar
    { "keys": ["ctrl+super+r"], "command": "reveal_in_side_bar" },

    // Create a new snippet
    { "keys": ["alt+super+n"], "command": "new_snippet" },

    // [HTMLPrettify] Format your HTML, CSS, and JS
    { "keys": ["super+shift+h"], "command": "htmlprettify" },

    // Close tag
    { "keys": ["super+."], "command": "close_tag" },

    // Alignment
    { "keys": ["super+shift+a"], "command": "alignment" },

    // Wrap selection in tag
    {
        "keys"      :   ["alt+shift+t"],
        "command"   :   "insert_snippet",
        "args": {
            "contents": "<${1:p}>${0:$SELECTION}</${1}>"
        }
    },

]

More info on Key Bindings can be found in the unofficial docs.

Sublime from the Command Line

Sublime Text includes a command line tool which you just need to symlink up so that it's in your PATH file. In Sublime Text 3 simply copy this into a terminal session:

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

Then you can open files in Sublime Text from the command line with:

subl my_file.txt

Replacing my_file.text with the name of the file or folder you wish to open in Sublime Text.

Useful Shortcuts

Commit these keyboard shortcuts to muscle memory; you'll amaze friends/colleagues w/editor wizardry. Pracice your skills with ShortcutFoo. The CheatSheet app will help while you're learning.

Default editor in Git

git config --global core.editor "subl -n -w"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment