Chris on Code
This tutorial is out of date and no longer maintained.
Sublime Text 3 is an amazing piece of software. To start, it is a clean, functional, and fast code editor. Not only does it have incredible built-in features (multi-edit and vim mode), but it has support for plugins, snippets, and many other things.
I know there have already been many articles like this online, but I am teaching a class on Sublime Text and thought it would be good to have all the information online. In this article, we’ll be diving into the best parts of Sublime Text. You’ve probably already heard of some of these, but maybe not some others.
The command palette lets you access pretty much anything in the settings menus, call your package commands, change file syntax, handle Sublime projects, and so much more.
For instance, you are able to call Git commands add, branch, commit, push, and pull all from the command palette.
To Use:
CTRL+SHIFT+P
Sublime Text provides a really fast way to open up new files. Just press CTRL+P
and start typing the name of the file you want. Once it shows up, just press enter and start typing directly into that file!
To Use:
CTRL+P
When you have a large file with a bunch of methods, pressing CTRL+R
will list them all and make them easier to find. Just start typing the one you want and press ENTER
.
To Use:
CTRL+R
Sublime Text 3 also has a new feature (Goto Definition). It provides Sublime Text with more capabilities closer to an IDE. Take a look at that if you’re interested.
This is in my opinion, the absolute best feature of Sublime. After using it here, it’s hard to go back to other text editors. There are many different ways to use multi-edit:
CTRL+D
: Select the current word and the next same wordCTRL+CLICK
: Every place you click will create a cursor to editCTRL+SHIFT+F
AND ALT+ENTER
: Find a word in your files and then select them allSnippets are yet another great feature of Sublime Text. You can use the pre-installed ones, build your own, or install a package that has more. All you have to do is type in a word and it will expand into your snippet. For example, typing lorem
will generate lorem ipsum text.
To Use: Type a word that activates a snippet (i.e.,
lorem
) and pressTAB
.
Here’s a great article on creating snippets.
The number of keyboard shortcuts in Sublime are astounding. This is my other absolute best feature of Sublime. The less I can move away from the home keys on my keyboard, the more efficient I can be.
For a full list of the Sublime Text Keyboard Shortcuts, take a look at our keyboard shortcuts article.
Projects are an integral part of my workflow in Sublime Text. A project is just a Sublime workspace in which your folders are open and stored in the sidebar. This helps since you can define a project and add folders to it, and be able to switch between folders quickly.
Using projects, you will no longer have to go digging in Windows Explorer or Finder to get the project you want and drag it into Sublime.
To Save a Project: Go into the command palette and type
save project
To Switch Projects:
CTRL+ALT+P
The absolutely necessary package manager for Sublime. This is the optimal way to install all of the plugins and themes listed below.
Go ahead and install that at the package control site.
To Use: Go into the command palette (
CTRL+SHIFT+P
) and typeinstall
.
Package Control will load all the packages available for install. Take a look at all the great things you can install and find your favorite packages.
A very simple and easy-to-use plugin. I’m a very big fan of making your code organized and good-looking. It helps tons when you revisit the code later down the road. Alignment helps with that.
To Use: Highlight the lines you want to align and press
CTRL+ALT+A
This plugin provides bracket highlighting for all sorts of brackets.
Have the ability to change colors with a color picker on the fly.
To Use:
CTRL+SHIFT+C
This plugin is much prettier when using it on Mac.
Emmet is an absolute time-saver. You can build HTML on the fly easily and quickly.
To Use:
CTRL+ALT+ENTER
and start typing your Emmet styled HTML
Check out our Emmet Interactive Guide to learn more and try out Emmet for yourself.
A really great way to easily create doc blocks for many languages including JavaScript, PHP, and CoffeeScript. Just type in /**
above your function and press tab
. Watch the magic as DocBlockr takes the function name and variables and creates your doc block.
Git helps you interact with your Git repo. It has support for all sorts of things like init
, push
, pull
, branch
, stash
, and more. Read more on how exactly you can
Using Git Inside of Sublime Text to Improve Workflow.
This is a small, but useful plugin that will tell you what lines have changed since your last Git commit. An indicator will show in the gutter next to the line numbers.
This plugin allows you to pull your Gists and insert them into your file. This is helpful when you have a Gist to start an HTML file or any other reusable code you have.
To Use: Open up the command palette and type
gist
.
You can also use the shortcuts that are shown.
This plugin provides a great deal more choices when right-clicking on a file in the sidebar. The ability to open, find, copy and paste, and more are all provided.
Here is the old menu vs the SidebarEnhanced menu.
There are some really cool-looking themes you can install for Sublime. You can find these by using Package Control.
Install a theme with Package Control and then update your User Settings to use it.
// User/Preferences.sublime-settings
{
"theme": "Soda Light.sublime-theme"
}
You might have to restart Sublime for these changes to take effect.
Some popular themes:
Comes with light and dark.
An offshoot of Flatland. Check out the repo and the great work by Jamie Wilson.
“A Hyperminimal UI Theme”. More information found here. Thanks to the link by Jentan Bernardus.
For more great themes, read up on the Best Sublime Text Themes of 2014.
In addition to changing your theme, you can also change your color scheme. These differ from themes since themes are packages for Sublime. Color Schemes are just a color scheme file and changing your settings.
To Change Color Scheme: Go into your menus,
Preferences > Color Scheme
, and select one.
You will see changes immediately and can check if you like it or not. For a list of some great color schemes, check out Dayle Rees’s colour schemes repo or color sublime, a great project.
Sublime comes with an insane amount of settings. I would encourage you to go look at everything it has to offer.
To get to your user settings, use the command palette and type in user
.
Here are my current settings, most are self-explanatory. Pick and choose the good parts for yourself and make your own custom settings!
// User/Preferences.sublime-settings
{
"bold_folder_labels": true,
"color_scheme": "Packages/Theme - Flatland/Flatland Monokai.tmTheme",
"font_face": "Ubuntu Mono",
"font_options": "subpixel_antialias",
"font_size": 14,
"highlight_line": true,
"highlight_modified_tabs": true,
"ignored_packages":
[
],
"line_padding_bottom": 1,
"line_padding_top": 1,
"rulers":
[
80
],
"scroll_past_end": true,
"tab_size": 4,
"tab_completion": false,
"theme": "Soda Light.sublime-theme",
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"vintage_start_in_command_mode": true,
"word_wrap": true
}
I use the great Vintage mode in Sublime. It provides vi editing commands inside of Sublime Text. It isn’t as fully featured as the original vi package, but it is the closest that I’ve seen in any text editor currently. That along with your keyboard shortcuts and command packages will make for a very fast developer.
The settings above automatically turn on Vintage mode when you open a file. If you don’t like this feature, just remove vintage_start_in_command_mode
, and if you want to disable Vintage altogether, remove the ignored_packages
setting.
There are so many parts to Sublime that I’m sure I missed some great things. Let me know if you find any other awesome packages or features and happy coding!
Note: Check out our very extensive series going over every aspect of Sublime Text 3:
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!