Getting Started with Sublime Text

November 19, 2013

Two years ago I converted to the church of Sublime Text and I’ve been preaching the good word ever since. It has become my primary editor for all my coding.

I’ve seen countless “getting started” guides for Sublime Text and don’t think any of them quite hit the right mark. There are only a few things you need to know to see immediate increases in productivity. This guide works not just for coders but also for designers, artists, or most anyone at a software/tech company.

What It Is and What It Isn’t

Sublime Text is a text editor. A very fast, efficient, cross-platform text editor written explicitly for editing code. It is not an IDE, debugger, or builder. It’s made to be super kick ass at editing text and not much else.

It’s also free to try! The trial duration is unlimited and has no paywalled features.

Step-by-Step

1. Install

Download the Sublime Text 3 beta for your favorite platform. You definitely want the ST3 beta and not the ST2 final release.

2. Add Files to Project

Click project in the top toolbar and add all the folders that contain the code and data you work with. Save this project file locally.

3. Goto File

File navigation in ST is fast. Wicked fast. Hit the Goto File shortcut, type any filename in your project, and hit enter. Voila! Near instant file navigation. No folder path memorization required.

Windows: Ctrl + P
OS X: Cmd + P

Goto File

4. Fuzzy String Matching

What makes the Goto File feature extra powerful is fuzzy string matching. File names don’t have to match exactly. Here’s a real-world example.

Fuzzy File Search

Given the search term “renmesh” here are the top results:

rasren_mesh_instance.cpp
rasren_batched_mesh_group.cpp 
ubernet_gameserver_service.h 
ubernet_gameserver_provider.h

Notice the bolded characters. No file name contained exactly “renmesh” but several contained those letters in that order. If you look closely at the ubernet results it actually contains the same letters in almost the same order.

Most, if not all, text completion in Sublime Text uses this fuzzy string matching and it’s delightful.

5. Goto Symbol

Goto Symbol is the same interface as Goto File except it works on symbols within a single file. Symbols are primarily functions but it includes things such as non-member variables as well.

Windows: Ctrl + R
OSX: Cmd + R

Goto Symbol

Fuzzy string matching works within the search results. If you were to type “handle” it would filter down to only WorldAudioHandle functions. Type “handlestart” and you can immediately jump to the function WorldAudioHandle::start.

6. Goto Anything

Goto Anything is the same Goto interface you know and love only it operates on raw text within a file. Functions, variables, comments, and everything else. It’s less commonly used but has it’s place.

Windows: Ctrl + ;
OSX: Cmd + G

Goto Symbol

7. Goto Symbol in Project

This is a major feature present in Sublime Text 3 but not in ST2. As the name implies, Goto Symbol in Project lets you navigate to any symbol (aka function) in any file in your entire project.

Windows: Ctrl + Shift R
OSX: Cmd + Shift + R

This one is actually a multi-step process. First you type the name of the symbol you are looking for.

Goto Symbol in Project

In this case the function we’re looking for is addUnit. When you hit enter it shows a list of files that symbol is found in.

File Results

After selecting the file you care about it a third step occurs to pick the instance of that symbol within the file. For functions this is often the declaration and definition.

The blinding speed at which this process happens can not be understated. I can zip through a codebase faster than any other tool I’ve ever used.

8. Goto Definition

Goto Definition is roughly equivalent to it’s Visual Studio counterpart. Mouse over a function that’s getting called, hit F12, and goto that function. It’s pretty much the same thing as Goto Symbol in Project minus a little typing.

Windows: F12
OSX: F12 or Cmd + Alt + Down

9. Fast File Switch

If you work in C/C++ all day like I do then fast switching between .h and .cpp files is a must. It’s only a keystroke away.

Windows: Alt + O
OSX: F12 or Cmd + Alt + Up

10. Packages and Plugins

Sublime Text enables user plugins through a Python interface. Package Control is package and website that lets you discover, install, and manage 3rd party packages. Package Control itself has been downloaded over 2 million times so suffice to say there is a lot of activity.

https://sublime.wbond.net/

Most of the packages target webdev which makes it a bit less useful for game devs. It’s definitely worth checking out once you get your feet a little wet.

11. Bonus Shortcuts

A few extra shortcuts that I personally use but don’t need an in-depth breakdown.

Split Pane View: Alt+Shift+2 / Cmd+Alt+2
Move Cursor by Word: Ctrl+Left/Right / not bound
Move Cursor by SubWord: Alt+Left/Right / Ctrl+Alt+(Left/Right)

12. Configuration

All configuration is done in simple JSON files. There’s no GUI with every option. There are two files you want to be aware of.

Preferences -> Settings — Default Preferences -> KeyBindings — Default

Both contain a near complete list of settings and keybindings that are available. There are matching user files you can use to override the default behavior. If you aren’t sure what the shortcut is for some action you can probably find it in the default file.

13. Workflow

Workflow is always a big topic for folks used to doing everything in an IDE. My work environment is all code editing in ST3, building from the command line, and debugging in Visual Studio. It works great and I have full debugging capabilities with zero issues.

14. Intellisense

Sublime Text 3 does not have intellisense. You can not get a list of functions available to an object. The good news is that raw text completion is really, really good and mostly makes up for it.

Furthermore, every professional project I’ve ever worked on intellisense has completely died so in that regard ST3 is a huge improvement. Visual Assist works a little longer, but it will eventually die or slow your IDE to a grinding, painful halt.

There are 3rd party packages that try to add code completion but in my experience they are slow and broken.

Conclusion

Sublime Text is awesome and you should use it. If you choose not to use it that’s ok, you’re not a bad person. But using it will make you a better person so you probably should.