Sublime Text Cheatsheet
Sublime Text 3 Cheatsheet: Boost Your Coding Productivity
This cheatsheet provides essential shortcuts and tips for Sublime Text 3, a powerful and popular code editor. Mastering these commands can significantly enhance your development workflow and efficiency.
Access Every Command with the Command Palette
Shift + Cmd + P: Open the Command Palette for quick access to all commands.
Navigate Swiftly with Goto Anything
Cmd + P: Quickly open files by name.Ctrl + G: Jump to a specific line number.Cmd + P: Utilize fuzzy search for files and commands.Cmd + R: Navigate to symbols (functions, classes, etc.) within the current file.
Efficient Selections and Multi-Cursor Editing
Cmd + D: Select the next occurrence of the current word.Cmd + K, Cmd + D: Skip the current selection and add the next occurrence.Cmd + U: Undo the last quick selection.Cmd + L: Select the entire current line.Ctrl + Cmd + G: Select all occurrences of the current selection in the file.Shift + Cmd + Space: Expand selection to the current scope (e.g., inside parentheses, quotes).Shift + Cmd + L: Split the current selection into multiple lines, one for each line selected.
Streamline Code Editing
Cmd + J: Join the current line with the next line.Cmd + Shift + D: Duplicate the current line or selection.Cmd + Shift + R: Re-indent the current selection or file according to syntax rules.Cmd + Shift + K: Delete the current line.Ctrl + Cmd + Up/Down Arrow: Move the current line or selection up or down.Alt + Cmd + V: Paste from the clipboard history.Shift + Cmd + /: Comment or uncomment the current line or selection.Alt + Backspace: Delete the word to the left of the cursor.Alt + Fn + Backspace: Delete the word to the right of the cursor (forward delete word).Cmd + Shift + Enter: Insert a new line above the current line.Cmd + Enter: Insert a new line below the current line.Ctrl + K, Ctrl + L: Convert the selection to lowercase.Ctrl + K, Ctrl + U: Convert the selection to uppercase.
Powerful Searching Capabilities
Cmd + F: Search for text within the current file.Shift + Cmd + F: Search for text across all open files and folders.<open files>: Use this as a filter in the search panel to limit searches to specific open files.
Miscellaneous Useful Commands
Alt + Cmd + Right/Left Arrow: Switch between open tabs.Ctrl + ]: Indent the current selection.Ctrl + [: Unindent the current selection.Alt + -: Go back to the previous cursor position.Alt + Shift + -: Go forward to the next previous cursor position.Ctrl + B: Build and execute the current file (if configured for the language).
Must-Have Sublime Text Packages for Developers
Enhance your Sublime Text experience with these essential packages. Install them via Package Control:
A File Icon: Adds file-specific icons to the sidebar.BracketHighlighter: Highlights matching brackets and tags.Color Highlighter: Displays colors inline for CSS/Sass/LESS.Comment-Snippets: Provides snippets for common comment formats.DevDocs: Integrates DevDocs.io for quick API documentation lookup.EditorConfig: Supports EditorConfig files for consistent coding styles.Emmet: A toolkit for high-speed HTML, CSS, and XML writing.File Rename: Provides a more robust file renaming experience.Git: Integrates Git version control features.Git blame: Shows Git blame annotations.GitGutter: Shows Git diff markers in the gutter.HTML-CSS-JS Prettify: Formats HTML, CSS, and JavaScript code.JavaScript Completions: Enhanced JavaScript autocompletion.JavaScript Patterns: Provides JavaScript code snippets.JavaScript Snippets: More JavaScript code snippets.LESS: Syntax highlighting and support for LESS.Nodejs: Node.js build system and autocompletion.Package Control: The essential package manager for Sublime Text.Pretty JSON: Formats and validates JSON data.SideBarEnhancements: Adds many new features to the sidebar.SublimeLinter: A framework for linting code.SublimeLinter-contrib-eslint: ESLint integration for SublimeLinter.Terminal: Opens an integrated terminal.Termius: SSH client and terminal emulator.Auto Save: Automatically saves files.
Customizing Your Sublime Text Preferences
Here's an example of a Preferences.sublime-settings file to customize your editor:
{
"color_scheme": "Packages/User/Color Highlighter/themes/Boxy Ocean.tmTheme",
"detect_indentation": false,
"folder_exclude_patterns":
[
"node_modules",
".svn",
".git",
".meteor/local"
],
"ignored_packages":
[
"Vintage"
],
"show_definitions": true,
"theme": "Adaptive.sublime-theme"
}
Custom Keybindings for Enhanced Workflow
Modify your keybindings to suit your preferences. Here's an example Default (OSX).sublime-keymap file:
[
{ "keys": ["super+v"], "command": "paste_and_indent" },
{ "keys": ["super+shift+v"], "command": "paste" },
{ "keys": ["super+shift+r"], "command": "reindent" },
{ "keys": ["super+h"], "command": "dev_docs_search_selection" }
]
Syncing Sublime Text Settings with iCloud
Keep your Sublime Text settings and packages synchronized across multiple Macs using iCloud.
Syncing Settings to iCloud:
- Navigate to the Sublime Text packages directory:
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages - Create a directory for your Sublime Text settings in iCloud Drive:
mkdir -p ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins - Move your existing
Userpackage (containing settings and keybindings) to the iCloud directory:mv User ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins - Create a symbolic link from the original location to the new iCloud location:
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins/User
Restoring Settings from iCloud:
- Navigate to the Sublime Text packages directory:
cd ~/Library/Application\ Support/Sublime\ Text\ 3/Packages - Remove the existing
Userdirectory:rm -rf User - Create a new symbolic link pointing to your
Userdirectory in iCloud:ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/WebDev/ST3/Plugins/User
By following these steps, you can ensure your Sublime Text configuration is always up-to-date and accessible from any of your Macs.