The user settings are a powerful tool for overriding some of Sublime’s default settings with ones that make it easier for you to work.

How to Access/Edit The Settings

In OS X, the settings are found through the “Sublime Text” > “Preferences” > finally “Settings - User”:

How to Access the User Preferences OSX

On Windows the settings are found through the “Preferences” menu and “Settings - User”:

How to Access the User Preferences Windows

This will open a new settings file which is a JSON formatted file that allows you to enter specific settings to override the default settings (which you can see by picking the “Settings - Default” option using the steps above).

The nice thing about this file is that it’s easy to make a backup and try new settings to see how Sublime Text reacts because it’s just a JSON formatted file. In a lot of cases you just need to make the change to the file, save, and the new setting will be in effect already.

Efficiency Settings

So the whole reason I’ve been writing this series of posts is to improve your efficiency in Sublime Text so I’ll start with these three settings:

"save_on_focus_lost": true,
"folder_exclude_patterns":[".svn",".git",".hg","CVS",".sass-cache"],
"spell_check": true,

The “save_on_focus_lost” does exactly what is says. If you switch away from Sublime Text or switch to a different file in Sublime Text the file automatically saves. This saves me a LOT of command+s keystrokes everyday and I’m guessing the amount of time this has saved me in incalculable.

The “folder_exclude_patterns” is helpful to ignore a set of folders. This does two things, the first is that it doesn’t show the folders in the sidebar and the second is that it excludes things from the “Goto Anything” window. I love this because I kept getting results from my .sass-cache folder which is just a bunch of binary data and isn’t helpful to anyone.

The “spell_check” setting enables spell check as you type. This feature is great because it highlights words that are misspelled as you type and reduces the number of tickets your QA team will have to enter to fix the spelling errors. Once it’s enabled you’ll see the standard red squiggly under the misspelled word and you can right click for some correction options or add the word to you dictionary (which is stored in your user settings under the “added_words” key).

image of spelling error

image of right click on spelling error

I’m a huge fan of having some kind of a coding standard because it gets all the programmers on your team using the same page and most standards are written to make your code easier to read. I highly recommend the coding standards outlined by PSR1 and PSR2 if you’re doing PHP develoment but if you need to you can create your own. There are some things you can do to make Sublime Text work better so it will work best with the PSR Standard (we’ll actually cover another way to do this on a per project basis later).

These are the settings you’ll want to change:

"rulers":[80,120],
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": false

The “rulers” setting draws a set of lines at 80 (soft line limit) and 120 (hard line limit) characters so you can easily see how many characters you have left.

image of rulers

The “translate_tabs_to_spaces” setting cause the tab key to use spaces instead of a tab character. There’s a big debate about tabs vs spaces but the PSR says spaces and I’m behind that based on my experience with both.

The “trim_trailing_white_space_on_save” setting removes any extra space at the end of a line. I have seen almost no cases where extra spaces at the end of a line causes problems but it helps you conform to the standard so I include it.

Bringing it All Together

So you can easily add this to your own settings this is why the whole file looks like:

{
    "folder_exclude_patterns":
    [
        ".svn",
        ".git",
        ".hg",
        "CVS",
        ".sass-cache"
    ],
    "ignored_packages":
    [
        "Vintage"
    ],
    "rulers":
    [
        80,
        120
    ],
    "save_on_focus_lost": true,
    "spell_check": true,
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": false
}