This is a set of plugins to empower Sublime Text 3 editor for regular developers. It's especially useful for git users.
Go to Packages
folder of Sublime Text (on MacOS, it is ~/Library/Application Support/Sublime Text 3/Packages/
), then clone this repo by running:
git clone https://github.com/ktuan89/sublimeplugins.git
Alternatively, you can open Sublime Text console and paste this line:
import os; path=sublime.packages_path(); (os.makedirs(path) if not os.path.exists(path) else None); window.run_command('exec', {'cmd': ['git', 'clone', 'https://github.com/ktuan89/sublimeplugins', 'sublimeplugins'], 'working_dir': path})
You can take a look at Default (OSX).sublime-keymap
to see all features and shortcuts.
Tip: If you want to change a shortcut or a setting value inside one of .sublime-settings
files, you can create a file with same name in ~/Library/Application Support/Sublime Text 3/Packages/User/
folder. Files with same name will be merged by Sublime Text and shortcuts/values in User
folder take precedence. By doing so, you can keep this repo clean and you can pull future fixes/improvements without conflicts.
By default, the plugin takes a look at your first open folder and use git repo of that folder. You can hardcode your own folder in Git.sublime-settings
.
Ctrl + g d
: Rungit diff
and show the result in Sublime Text.Ctrl + g s
: Rungit show
and show the result in Sublime Text.Command + Shift + \
: If you are viewinggit diff
orgit show
content, this shortcut brings you to the file you are viewing (under the current cursor) at the exact position.Ctrl + g o
: If you are rebasing and having conflicts. It will list all files with conflicts and you can open these files in Sublime Text.Ctrl + g a
: Mark the conflicted file as resolved. This is flaky for some reason so I usually use git command line directly.Ctrl + g b
: Show blame inline with current view.Ctrl + g r
: Remove the blame shown.Command + Shift + b
: Show blame page on web browser, configurable usingweb_blame_url
value inGit.sublime-settings
.
Command + Shift + t
: Grep for a text. Currently I usegit grep
as my codebase is quite big. You can change settings inGrep.sublime-settings
- You can also hardcode your grep command in key shortcut settings. It's useful to have different shortcuts searching in different folders:
{ "keys": ["super+shift+y"], "command": "grep", "args": {"ask": true, "show_in_view": true, "grep_command": "cd /path/to/folder/;grep -rn {0} ."} }
- You can also hardcode your grep command in key shortcut settings. It's useful to have different shortcuts searching in different folders:
Command + Shift + \
: If you are viewing grep result file (result of the previous command), this shortcut brings you to the file under the cursor. It's actually the same shortcut with number 3 ofGit Integration
. If you are selecting multiple lines, it will open all files under selection.Command + Ctrl + s
: If you are viewing grep result file (result of the 1st bullet point) and you make some changes in this file, the changes are written back to original files. For example, you canCommand + Shift + t
to grep forMyFunctionName
, change it toMyFunctionName2
, and use this short cut to save this modification to all files that haveMyFunctionName
.Command + Ctrl + \
: Similar toCommand + Shift + t
but it shows the results in a searchable dialog instead of a new view.Ctrl + Enter
: Perform a "quick grep". It uses the current word under the cursor without asking you again. It looks for the word preceeded by wordclass|protocol|struct|etc
so it always look for definition of the word in codebase. If there is only one result, it brings you to the file immediately. Take a look atquick_grep_format_str
option inGrep.sublime-settings
to see how it works.
Command + Shift + o
: List all open files so that you can search for a file name and open it.Command + Shift + i
: List all files in the same folder with current file. This is useful when you structure files iCtrl + \
: List all files (among open files) which contain the current word (under the cursor). Generally this command isn't useful as it is replaceable by one of Grep commands.Ctrl + o
: Open the current file in Xcode. If your are opening Xcode project has the file, it will open the file under that project.Ctrl + 0
: Open the folder of the current file in Finder.Ctrl + 9
: Open the folder of the current file in Terminal.Command + number
(from 1 - 9): By default, Sublime will open one of your first-opened files (with 1 is the first ever opened file). This isn't useful when you work on a project with 20+ files. You probably don't even remember when you opened the first file. If you set"use_recent_file_navigation": true
in Sublime Preference settings, it reverts the behavior. For example,Command + 1
will open the previous file,Command + 2
will open the file before the previous file, etc.
Ctrl + w
,Ctrl + e
: Go to the previous/next occurrence of the current word (under the cursor). It avoids "copy-search-paste-enter" sequence of keys.Ctrl + f
: Filter and only keep lines that contain a string. Prefix the string with minus (-
) char to filter lines that don't contain the string.Ctrl + [
to mark the beginning of a selection andCtrl + ]
to mark the end. Useful to select a large block of text.Ctrl + c
: Copy (to clipboard) current word under the cursor - no need to select the word.Ctrl + r
: Replace the current word with something else. It affects all occurrences of current file. Prefix the string with#
to replace in all open files.- BUCK syntax: If you are using BUCK build system from Facebook, you can notice that BUCK file is actually a python file but Sublime Text doesn't highlight the file in python syntax. One of the plugins fixes the issue.
Although I have done most of the coding by myself. I copied and/or was inspired by:
- Sublime's Extended Tab Switcher with modifications to fit to my own work flow.
- Facebook internal tools for code search.
MIT