Sublime Text Tips


I’ve been use Sublime Text on my Mac for 2 years now and still it has many unknown features that would surprise me now and then. However, sometimes I do forgot about features, so I write this article as a reminder of future configuration and usage guide.

Basic Setting

Normal Setting of Sublime Text is done in Preference/Setting part, notice that usually one only need to adapt User setting and keep Default setting as it is.

My user setting is like this:

{
    "folder_exclude_patterns":
    [
        "log",
        ".git",
        "cache"
    ],
    // This three line make my code reading faster.
    "font_size": 16,
    "highlight_line": true,
    "indent_to_bracket": true,
    // I'm not a very good typer so I need this, but some people may find it annoying since it keeps telling you your perfect variable name is wrongly spelled. :)
    "spell_check": true,
    // This last three is very helpful if you really care about clean code.
    "translate_tabs_to_spaces": true,
    "trim_trailing_white_space_on_save": true,
    "ensure_newline_at_eof_on_save": true
}

Setup command line

Next step is to open files and directories from command line using Sublime Text, the installation didn’t do it for you so you need to do it by yourself, luckily it is not hard at all. :)

According to the documentation here

What you need to do is simply:

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

But you also need be careful about your bash profile configuration, make sure to add /usr/local/bin in your export PATH and if you’re using zsh like me, make sure to change the configuration of zsh as well.

I don’t suggest to adapt default editor in terminal to Sublime Text though, when I used it as default editor there is some saving issues I encountered.

Package Control

Package Control is another amazing thing about sublime text you can always find the package you want here, several packages I used most often is as below:

Abacus It’s small and it’s old, but it is useful enough for alignment.

Markdown Preview I used it a lot, it can build github-markdown-like pages.

DashDoc Dash + Sublime Text

Searching in Sublime Text is amazing, actually that’s why I fall in love with it in the first place.

Search current page is basically accomplished by Command+F, You can also use Command+P, where you input @ sign to search for function and classes and input : sign to search line number, and input # to search anything. But I mostly use Command+P to search for file names in current directory, it has super good fuzzy search support so basically you can type anything in your head and it will help you open the file you want.

To search words in files, the command you need is Command+Shift+F, notice that it also support regular expression search by press Alt+Command+R (after press Command+Shift+F), case sensitive search by press Alt+Command+C.

You can also use fuzzy search on file locations too, you can put /dir/, *.csv as your search location and then it will only do search in csv files.

Another trivial tip

To bulid your code(I’m refering to simple snippit here) from the editor, simply push Command+B, you can also write your own build method if you like. I write my own tcl build method (What is tcl?) for instance.

What’s next

I learned most of the tricks in Sublime Text Unofficial Documentation, hope to learn more as time goes by.