DEV Community

Cover image for 30+ Sublime Text 3 shortcuts to code a lot faster.
Patrik Kiss
Patrik Kiss

Posted on

30+ Sublime Text 3 shortcuts to code a lot faster.

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

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.

Jump to file

2.Jump to line

Windows MAC
CTRL+G ⌃+G

You can directly jump to any line you want easily.

Jump to line

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.

Command prompt

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.

reopen

5.Toggle Distraction-free mode

Windows MAC
Shift+F11 ⌃ + ⇧ + ⌘ + F

distraction free

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.

search method

7.Toggle clipboard

Windows MAC
CTRL+K+V ???

With this you can toggle a popup with the last 15 of your copies.

Toggle clipboard

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.

Toggle sidebar

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.

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.

Duplicates

3.Duplicate line

Windows MAC
CTRL+Shift+D ⌘ + ⇧ + D

Duplicates the current line, or the selected area.

Duplicate

4.Select content of an element

Windows MAC
CTRL+Shift+A ⌘ + ⇧ + A

You can easily select the whole content inside an element in HTML.

Select content

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.

Move up/down

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.

alt

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.

Add new line

8.Replace two selection

Windows MAC
CTRL+T ⌘+T

Simply replace two selections with this command, instead of doing it manually all the time.

Replace selections

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.

Jump by words

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.

Select by words

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.

Delete to start

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.

Delete to end

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.

Sort

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.

All occurrences

15.Delete tab

Windows MAC
Shift+Tab ???

Simply delete a tab before the selected area.

Delete tab

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.

Jump to matching brackets

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.

Transform

18.Close HTML tags

Windows MAC
Alt+. ⌘ + ⌥ + .

Simply close all the tags that are missing the closing tag.

Close tags

19.Skip selection

Windows MAC
CTRL+K+D ???

When selecting duplicates, you can skip the next with this shortcut.

Skip selection

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

Wrap selection

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.

Search

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.

Replace

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.

Search in files

Top comments (7)

Collapse
 
dzdevelop profile image
dzdevelop

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!

Collapse
 
b4two profile image
Batuhan

Why do you use sublime text instead of vscode?

Collapse
 
weeb profile image
Patrik Kiss • Edited

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.

Collapse
 
b4two profile image
Batuhan

Does it have extensions like Live Sass Compiler, Live Share, Live Server, Autoprefixer etc. ?

Thread Thread
 
grasmachien profile image
grasmachien

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.

Collapse
 
choallin profile image
Gernot Gradwohl

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. :-)

Collapse
 
joshbrw profile image
Josh Brown

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!