I have seen several posts about keyboard shortcuts for VS Code, and they were all really informative and well-written.
But unfortunately I haven't seen any about Sublime Text yet, even though those who use it, like myself, would probably find it very useful.
So since there isn't one yet, I decided to write one myself.
I've collected 30+ shortcuts for Sublime Text 3 I find the most useful.
Before every shortcut you will find an arrow which leads back here
Post content
- Jump to file
- Jump to line
- Open command prompt
- Reopen last closed file
- Toggle Distraction-free mode
- Search methods
- Toggle clipboard
- Toggle sidebar
- Select line
- Select duplicates
- Duplicate line
- Select content of an element
- Move active line/selection up/down
- Add cursor to next/previous line
- Insert new line before/after
- Replace two selection
- Jump by words
- Select by words
- Delete from cursor to the start of active line
- Delete from cursor to the end of active line
- Sort
- Select all occurrences of selected word(s)
- Delete tab
- Jump to matching brackets
- Lower/uppercase selection
- Close HTML tags
- Skip selection
- Wrap selection in HTML tag
- Find/search
- Find and replace
- Find/search in all opened file
General
⇧1.Jump to file
Windows | MAC |
---|---|
CTRL+P |
⌘ + P /⌘ + T
|
You can directly jump to any of the opened files quickly. Also, as you are typing the name of the file, ST3 opens the most relevant one by itself.
It also keeps a track of which files you have opened the most often, so it will automatically put them on the top, thus opening it already.
⇧2.Jump to line
Windows | MAC |
---|---|
CTRL+G |
⌃+G |
You can directly jump to any line you want easily.
⇧3.Open command prompt
Windows | MAC |
---|---|
CTRL+Shift+P |
⌘ + ⇧ + P |
With this you can open the command prompt where you can execute various commands, such as install package controll or package for example.
⇧4.Reopen last closed file
Windows | MAC |
---|---|
CTRL+Shift+T |
⌘ + ⇧ + t |
Accidentally closed a file? Yeah we all do that sometimes. So instead of opening the current folder(CTRL+O
) and start looking for that file, just use this shortcut to open the file you have last closed.
⇧5.Toggle Distraction-free mode
Windows | MAC |
---|---|
Shift+F11 |
⌃ + ⇧ + ⌘ + F |
⇧6.Search methods
Windows | MAC |
---|---|
CTRL+R |
⌘ + R |
This will toggle a list of all methods in your active file, and you can search them.
⇧7.Toggle clipboard
Windows | MAC |
---|---|
CTRL+K+V |
??? |
With this you can toggle a popup with the last 15 of your copies.
⇧8.Toggle sidebar
Windows | MAC |
---|---|
CTRL+K+B |
⌘ + K, ⌘ + B |
Many might not know, but Sublime Text has a sidebar too. Might not be as advanced by default as that of VSCode, but it can still be useful.
Editing
⇧1.Select line
Windows | MAC |
---|---|
CTRL+L |
⌘+L |
Selects the current line. By repeating this command, you can keep on selecting the next lines.
⇧2.Select duplicates
Windows | MAC |
---|---|
CTRL+D |
⌘+D |
By repeating this command, you can select the occurrences of the current selection in the file.
Each time you use it, the next occurrence is being selected as well. By holding down the keys, it works a lot quicker.
⇧3.Duplicate line
Windows | MAC |
---|---|
CTRL+Shift+D |
⌘ + ⇧ + D |
Duplicates the current line, or the selected area.
⇧4.Select content of an element
Windows | MAC |
---|---|
CTRL+Shift+A |
⌘ + ⇧ + A |
You can easily select the whole content inside an element in HTML.
⇧5.Move active line/selection up/down
Windows | MAC |
---|---|
CTRL+Shift+Up/Down |
⌘ + ⇧ + Up/Down |
Move the active line or your selection up and down simply like that.
⇧6.Add cursor to next/previous line
Windows | MAC |
---|---|
CTRL+Alt+Up/Down |
⌃ + ⇧ + Up/Down |
You can add another cursor at the same position as the original one to the next/previous line.
⇧7.Insert new line before/after
Windows | MAC |
---|---|
CTRL (+Shift )+Enter
|
⌘ + (⇧ )+↩
|
With CTRL+Shift+Enter
you can insert a new line before the cursor, with CTRL+Enter
you insert one after the cursor.
⇧8.Replace two selection
Windows | MAC |
---|---|
CTRL+T |
⌘+T |
Simply replace two selections with this command, instead of doing it manually all the time.
In case you don't know how to make multiple selection, just hold CTRL
when selecting something.
⇧9.Jump by words
Windows | MAC |
---|---|
CTRL+ (Left /Right ) |
⌘+ (Left /Right ) |
Instead of simply just holding down the right arrow to get the cursor where you want, just use this command to get there much quicker by skipping a whole word with each jump.
⇧10.Select by words
Windows | MAC |
---|---|
CTRL+Shift+ (Left /Right ) |
⌘ + ⇧ + (Left /Right ) |
You can also easily select multiple words easily by using the same method as above, but also holding Shift
down. With this you will still jump by words, but you will also select everything.
⇧11.Delete from cursor to the start of active line
Windows | MAC |
---|---|
CTRL+K+Backspace |
⌘ + K + ⌫ |
This will delete everything from the cursor's position to the start of the currently active line.
⇧12.Delete from cursor to the end of active line
Windows | MAC |
---|---|
CTRL+K+K |
⌘ + K, ⌘ + K |
This will delete everything from the cursor's position to the end of the currently active line.
⇧13.Sort
Windows | MAC |
---|---|
F9 |
F5 /⌃ + F5
|
You can sort the selected area by the first characters with a simple keypress if you want to.
⇧14.Select all occurrences of selected word(s)
Windows | MAC |
---|---|
Alt+F3 |
⌘ + ⌃ + G |
Similar to CTRL+D
, but this will select all occurrences of your selection if the active file.
⇧15.Delete tab
Windows | MAC |
---|---|
Shift+Tab |
??? |
Simply delete a tab before the selected area.
⇧16.Jump to matching brackets
Windows | MAC |
---|---|
CTRL+M |
⌃ + M |
Why you select an opening bracket, with this shortcut you can jump directly to the closing tag.
⇧17.Lower/uppercase selection
Windows | MAC |
---|---|
CTRL+K+ (U /L ) |
⌘ + K, ⌘ + (U /L ) |
You can quickly transform the selected section to lower or uppercase.
For lowercase, use CTRL+K+L
, for uppercase use CTRL+K+U
.
⇧18.Close HTML tags
Windows | MAC |
---|---|
Alt+. |
⌘ + ⌥ + . |
Simply close all the tags that are missing the closing tag.
⇧19.Skip selection
Windows | MAC |
---|---|
CTRL+K+D |
??? |
When selecting duplicates, you can skip the next with this shortcut.
⇧20.Wrap selection in HTML tag
Windows | MAC |
---|---|
Alt+Shift+W |
??? |
Easily wrap the selection in a HTML tag. It is wrapped in a p
tag by default, but just start typing and you will rename both the opening and closing tag
Find/replace
⇧1.Find/search
Windows | MAC |
---|---|
CTRL+F |
⌘ + F |
This is a basic search command, to quickly find what you're looking for in your currently active file.
⇧2.Find and replace
Windows | MAC |
---|---|
CTRL+H |
⌘ + ⌥ + F |
With this you can find each occurrence of something in your active file, and can replace it with something else, one by one, or all of them immediately.
Use CTRL+Shift+H
to replace them one by one, and CTRL+Alt+Enter
to replace all.
⇧3.Find/search in all opened file
Windows | MAC |
---|---|
CTRL+Shift+F |
⌘ + ⇧ + F |
If you want to search for something in several/all files, this is your option to do it.
You can quickly search for anything in all opened files, and the search results will be opened in a new tab, listing all the matches, the file name and the line where the search value occurred.
Quickly open the results with Alt+Enter
shortcut.
Top comments (7)
Great job! Thanks for sharing I'll try to add some of these to my everyday typing. I'll leave some notes I hope can be helpful.
About "15.Delete tab": I'm on MAC and "shift+tab" works just fine, if you want to replace the "???".
About "10.Select by words": I use that shortcut to select by line, if I use the right arrow it select-jumps to the end of line, if I use the left one it select-jumps to the start (ignoring leading tabs. to get those as well i need to press the left arrow again).
Maybe those two are just on my settings and don't work the same way for others? I'm not sure, sorry!
Why do you use sublime text instead of vscode?
Because I like it much more.
I've been using it for nearly 2 year now, and I'm very much used to it. I've tried VSCode, but I didn't like it. Sublime is simple, easily understandable, and still has everything I need. If it doesn't include something by default, there are hundreds of packages I can choose from, so I always find what I need.
Does it have extensions like Live Sass Compiler, Live Share, Live Server, Autoprefixer etc. ?
Not sure about those extensions but why would I want to have these in my editor when my npm/webpack build tools handle all of these things for me.
That way all developers on a project can use the editor they prefer and still work in exactly the same way.
If you work alone doing all of those things in your editor is probably fine.
I recently tried to switch to VS Code and forced myself to use it for ~ 6 months. In the end I switched back to Sublime Text.
For me, VS Code is simply to slow and eats all resources it can get If I would like to have something this heavy I would use a full fledged IDE instead.
Sublime has not as much plugins as vs code but it has everything I need and the community is still very active. :-)
Great article!
If you're writing PHP, may I suggest you try PHPStorm. It'll hugely improve the quality of your code, but it does take some getting used to!