By josh / December 23, 2012

How to track down shortcuts in Sublime

Sublime Text has keyboard shortcuts for almost everything, but it’s sometimes hard to track them down. Here a few strategies that will help you uncover the shortcuts for all of your favorite features.

First of all, dedicate a few minutes browsing through Sublime’s menus. Looking at the menus when you’re not already on a mission to find something specific is a great way to discover new features. And in many cases, the keyboard shortcuts are listed right next to the command, which provides a handy reference if you forget a less frequently used shortcut.

Once you’re comfortable with how the menu is arranged, pretend it doesn’t exist. Instead, get comfortable using the Command Palette for everything. The Command Palette is Sublime’s equivalent of an Easy Button—you can use it to perform almost any command without reaching for the mouse, even if you can’t remember the keyboard shortcut. Using it gets you out of the habit of reaching for the mouse all the time, and it’s still usually faster than using the menus. And as you enter commands, take note: In many cases the keyboard shortcuts are listed right next to the name of the command.

When you can’t find the shortcut in the menus or Command Palette, it’s time to dig around in the configuration files. Open the default keybindings file for your operating system by launching the Command Palette and entering “keybindings default.” This is the master file where Sublime defines all of its default keyboard shortcuts. It’s not always obvious what the shortcuts are mapped to because the shortcuts use the Sublime API terms for commands, but you can often find what you’re looking for. For example, the Distraction Free Mode shortcut, which I was trying to remember while writing this email, is Command+Shift+Ctrl+F on my MacBook. If you search for “distraction” in the keybindings file, you’ll see that this shortcut is bound to the command “toggle_distraction_free”. Clear enough.

Tracking down keyboard shortcuts for plugins is a little trickier, as most won’t show up in the Command Palette or application menus. But since all keyboard shortcuts are defined in easily readable JSON-formatted files , you can uncover them with a little detective work. Open the Command Palette and type “Browse Packages” to open the Packages folder, then hunt around for the name of the plugin you’re interested in. Once you find the folder, look for the keybinding file, which will have a .sublime-keymap extension.

Many plugins put a link to the keybindings file under the Preferences | Package Settings menu, which is a lot more convenient than hunting through folders. If your favorite plugin doesn’t include a menu entry for its keyboard shortcuts, consider creating the entry yourself and submitting a pull request to the plugin’s owner. I did this for the MarkdownEditing plugin, and the owner accepted my contribution within a few days. Here’s a link to the change I submitted so you can see what’s involved:

https://github.com/joshearl/MarkdownEditing/commit/7124d2d8ef0964d918d6cc23e4e0b7bc66898932

P.S. Want to improve your mastery of Sublime Text? Start here:

http://sublimetexttips.com/newsletter

About the author

josh

Click here to add a comment

Leave a comment: