Although I switched to Sublime Text more than a year ago, I only recently decided to take a good look at my configuration, with the end goal of increasing my productivity. What follows are my settings, which will hopefully help others work a bit smarter. If you’ve got any useful tips, please tweet at me!
Hide Files and Folders
It’s often helpful to hide folders so they’re not found when searching or using the Go to File shortcut (⌘ + T). Add the following line to your User Preferences (Preferences › Settings - User or ⌘,) to do so:
You can also use exclude file types (with asterisk), instead of directories:
Open Files as Tabs
The default behavior is to open a file in a new window. If you’d prefer tabs, add this line to your User Preferences (Preferences › Settings - User or ⌘,):
Close Windows when Empty
To close the window when there are only empty tabs, add this line to your User Preferences (Preferences › Settings - User or ⌘,):
Some projects use tabs, while others use spaces. It’s nice to easily copy and paste snippets of code between the two, without worrying about the indentation.
To adjust your indentation to match the context in which it’s pasted, use “Paste and Indent” for ⌘V instead of the standard “Paste.”
To do this, add the following in your Key Bindings - User file:
There are a lot of really useful keyboard shortcuts in Sublime Text. Instead of listing them all, I’m going to list some favorites. With a quick search of the internet you’ll surely find more to integrate into your workflow.
- ⌘L - Select line
- ⌘D - Select word (use this to select other occurrences, which is great for multiple editing)
- ⌘P - Goto anything (use # to search within file and : to go to a line number)
- ⌘⌃G - Select all occurrences of current word (again, helpful for multiple editing)
- ⌃⌘↑ (up) or ↓(down) - Swap lines either up or down
More Info: Here’s a Gist of Useful Shortcuts.
One of the best things about Sublime Text is how extensible it is. There are hundreds of community developed plugins and with Package Control it’s quick and easy to install, update, and remove them from your installation.
- Open Sublime Text and press ctrl ` (control backtick) to open the editor’s console.
- Paste in the following code:
- All Autocomplete - Allows autocompletion across open files
- Color Highlighter - Underlays selected hexadecimal color codes (like “#FFFFFF”, “rgb(255,255,255)”, “white”, etc.) with their real color
- CSS Color Converter - Convert hex to rgb to back
- CSS3 - The most complete CSS support for Sublime Text 3
- EditorConfig - Editor Config helps define and maintain consistent coding styles between different editors and IDEs
- GitHub Tools - A set of handy tools for using Sublime Text editor with Github
- Inc-Dec-Value - increase / decrease of numbers, dates, hex color values, etc
- LESS - LESS syntax highlighting
- Modific - Highlight lines changed since the last commit
- SideBarEnhancements - Adds useful file operations to the sidebar, such as “New file”, “New folder”, etc
- SublimeLinter - Lint code as you type
- SublimeLinter-csslint - SublimeLinter plugin for CSS, using csslint
- SublimeLinter-contrib-scss-lint - SublimeLinter plugin for Sass scss syntax, using scss-lint
- SublimeLinter-json - SublimeLinter plugin for JSON
- Syntax Highlighting for Sass - Sass syntax highlighting
- TrailingSpaces - Strips trailing whitespace from files.
There are also innumerable packages to support syntax highlighting, linting, and snippets in any and all languages. You can easily discover these via Package Control.
Open TrailingSpace’s preferences (Preferences › Package Settings › TrailingSpaces › Settings - User), and add:
Also add this to your global user preferences (⌘,):
Tabs to Spaces
The default indentation style uses tabs instead of spaces. If you want to change this, go to your User Preferences (Preferences › Settings - User or ⌘,) and add:
To scroll past the end of the file, add this to your User Preferences (Preferences › Settings - User or ⌘,):
There are a multitude of resources available to users of Sublime Text. Here are some good ones to read through: