Skip to content

Instantly share code, notes, and snippets.

@anotheruiguy
Last active November 6, 2020 23:30
Show Gist options
  • Save anotheruiguy/11054534 to your computer and use it in GitHub Desktop.
Save anotheruiguy/11054534 to your computer and use it in GitHub Desktop.
A quick list of things to make Sublime awesome

There are a lot of great articles out there on how to set up Sublime text and all the reasons behind those choices. This is NOT one of those :)

Here is a quick list of things that are really popular with Sublime users.

Link Bash to Sublime

On the Mac - run this command in Terminal

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

On Windows - follow these directions

Launch Sublime Text From the Command Line in Windows

Install Package Manager in Sublime

Follow these directions - Install Sublime Package Control

Really cool keyboard commands for using Sublime

Open the Commands Window command + shift + p

Quick switch between open files command + t

Search and replace command + f + <enter string> + command + d

pro tip: command + e put selected string into find field

select a line command + l

Project search command + shift + f

Split windows

command + option + shift + 1/2/3

command + option + shift + 1/2/3

Move the current tab to a new pane

option + control + shift + 2/3

Sort CSS alpha

select lines to sort + f5

Find your selectors

command + r

Recommended preferences in Sublime

Protip: When setting preferences in Sublime text, NEVER use preferences > Settings - Default. When you upgrade Sublime Text, there is a god chance that these will get completely re-written and any changes/customizations you make will get blown away!

Instead, what you want to edit is your preferences > Settings - User. When you first open this file, this most likely will be empty. The following is a good example of some popular settings:

{
	// OS X only: This controls if an empty window is created at startup or not.
	"create_window_at_startup": false,

	// Set to true to ensure the last line of the file ends in a newline
    // character when saving
	"ensure_newline_at_eof_on_save": true,

	// Set your p[referred font size]
	"font_size": 15.0,

	// If enabled, will highlight any line with a caret
	"highlight_line": true,

	// Additional spacing at the bottom of each line, in pixels
	"line_padding_bottom": 1,

	// OS X only: When files are opened from finder, or by dragging onto the
    // dock icon, this controls if a new window is created or not.
	"open_files_in_new_window": false,

	// remember_open_files makes the application start up with the last set of
    // open files. Changing this to false will have no effect if hot_exit is
    // true
	"remember_open_files": false,
	"hot_exit": false,

	// Set to true to automatically save files when switching to a different file
    // or application
	"save_on_focus_lost": true,

	// Set to false to disable scrolling past the end of the buffer.
    // On OS X, this value is overridden in the platform specific settings, so
    // you'll need to place this line in your user settings to override it.
	"scroll_past_end": true,

	// The number of spaces a tab is considered equal to
	"tab_size": 2,

	// Set to true to insert spaces when tab is pressed
	"translate_tabs_to_spaces": true,

	// Set to true to removing trailing white space on save
	"trim_trailing_white_space_on_save": true,

	// Disables horizontal scrolling if enabled.
    // May be set to true, false, or "auto", where it will be disabled for
    // source code, and otherwise enabled.
	"word_wrap": true,

	// List any packages to ignore here. When removing entries from this list,
    // a restart may be required if the package contains plugins.
	"ignored_packages":
	[
		"Block Cursor Everywhere",
		"Vintage"
	]
}

Avoid trailing commas

Setting preferences in Sublime is editing code. If there is an error with the code, there is a good chance that Sublime will break and break hard.

All the preferences use a "key"; "value" pair syntax. When there is a pair is that is followed by another pair, this requires a trailing comma like so:

{
	"key": "string-value",
	"key": 
	[
		"value",
		"value"   <- NO COMMA!!
	],		
	"boolean": true   <- NO COMMA!!
}

Notice that the last line DOES NOT have a comma.

More good reading

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