Essential Shortcuts and Configuration for Sublime Text 3
Choosing Between Sublime Text 2 and Sublime Text 3
While both versions are similar, Subllime Text 3 is recommended due to its updated UI and package management. Package files install directly within the Sublime Text 3 directory instead of separate system locations, making it portable and easier to backup configurations.
Adding Sublime Text to the Right-Click Context Menu
- Open the Registry Editor by running
regeditfrom the command line. - Navigate to
HKEY_CLASSES_ROOT\*\Shell. - Create a new key named "Edit with Sublime Text 3".
- Within this key, create a new String Value named
Iconand set its value to"C:\Program Files\Sublime Text Build 3065\sublime_text.exe,0"(adjust the path to your installation). - Create a subkey named
Commandand set its default value to"C:\Program Files\Sublime Text Build 3065\sublime_text.exe" "%1". - The option will appear in the context menu immediately.
Basic Interface Configuration
Default settings are in Preferences > Settings-Default. Override them by adding entries to Settings-User. For example, to set font size, highlight the current line, and bold sidebar folder icons, add:
{
"font_size": 12,
"highlight_line": true,
"bold_folder_labels": true
}
Changes save instantly with Ctrl+S.
Frequently Used Keyboard Shortcuts
Default shortcuts are listed in Preferences > Key Bindings-Default. Customize them in Key Bindings-User.
- Format Code: Alt+Shift+F (Custom) - Formats selected code.
- Fold Code: Ctrl+Shift+[ (Custom) - Collapses code within a method.
- Reopen Closed Tab: Ctrl+Shift+T (Default)
- Toggle Full Screen: F11 (Default)
- Distraction-Free Mode: Shift+F11 (Default)
- Quick Add Selection: Ctrl+D (Default) - Selects next occurrence of the current word. Ctrl+U steps back.
- Close Panels: Esc (Default) - Closes search/replace panels.
- Insert Line Above: Ctrl+Shift+Enter (Default)
- Move by Word: Ctrl+Left/Right Arrow (Default)
- Go to Symbol: Ctrl+R (Default) - Shows a list of methods/functions in the current file.
- Set Layout: Alt+Shift+1/2/3 (Default) - Switches between single, double, or triple colum layouts.
Useful Plugins
Install Package Control first to simplify plugin management.
Installing Package Control
- Open the console via View > Show Console.
- Paste the following code and press Enter:
import urllib.request, os, hashlib; h = '6f4c264a24d933ce70df5dedcf1dcaee' + 'ebe013ee18cced0ef93d5f746d80ef60'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener(urllib.request.build_opener(urllib.request.ProxyHandler())); by = urllib.request.urlopen('http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join(ipp, pf), 'wb').write(by)
- After installation, use Ctrl+Shift+P, type "Install Package" to add new plugins or "Remove Package" to delete them.
BufferScroll Plugin
This plugin preserves code folding states between sessions. Install via Ctrl+Shift+P > Install Package > BufferScroll.
Configuring Xdebug for PHP Debugging
PHP Xdebug Setup
- Create a PHP file with
<?php phpinfo(); ?>and view its source code in a browser. - Visit the Xdebug Wizard, paste the source code, and follow the instructions to install the correct Xdebug extension.
- Add these lines to your
php.inifile:
zend_extension="path/to/xdebug.so" ; Use full path to the extension
xdebug.mode=debug
xdebug.client_host=127.0.0.1
xdebug.client_port=9003
xdebug.start_with_request=yes
- Restart your web server.
Sublime Text Xdebug Client Setup
- Install the Xdebug client plugin via Package Control (search for "Xdebug").
- Configure user settings via Tools > Xdebug > Settings - User. Example configuration:
{
"path_mapping": {
"/var/www/html/": "C:/Projects/myapp/"
},
"url": "http://localhost/myapp/",
"super_globals": true,
"close_on_stop": true
}
- Define custom keyboard shortcuts for debugging in Preferences > Key Bindings - User:
[
{ "keys": ["f5"], "command": "xdebug_session_start" },
{ "keys": ["shift+f5"], "command": "xdebug_session_stop" },
{ "keys": ["f6"], "command": "xdebug_session_run" },
{ "keys": ["f10"], "command": "xdebug_session_step_over" },
{ "keys": ["f11"], "command": "xdebug_session_step_into" }
]