7 shortcuts of a highly effective Sublime Text user
Kiran Koduru • Oct 24, 2017 • 5 minutes to read • Last Updated: Oct 31, 2017Through my career as a software developer, I have appreciated one text editor the most, Sublime Text. I began with writing code in Notepad++ long long time ago, then tried IDEs as well but nothing came as close to working smoothly as Sublime Text. This blog is also written using Sublime Text.
Once you have imported your project into Sublime Text workspace, using the following 7 shortcuts will help you get close to being a Sublime Text power user.
Goto Anywhere
IDEs have a shortcut key to goto a class name, a different one to goto a function name and another one for symbols. This can cause a lot of confusion on how to navigate a file. And if you are anything like me, you’d end up carrying a cheat sheet to look up each time.
For Sublime Text, all you have to do is hit Ctrl + R
or ⌘ + R
on Mac OS to navigate to any function/class/symbol in the file you are currently editing.
Open any file
While you could search for a filename through your operating system easily, Sublime Text allows you to goto any filename fairly quickly. Just hit Ctrl + P
or ⌘ + P
to open any file in your workspace.
Show/Hide sidebar
Some people prefer working with more than one monitor. I personally like having a distraction free screen and seldom resort to using more than one screen. For times like these, I need more screen space for code.
I toggle my Sublime Text sidebar by hitting the following keys in succession Ctrl + K
and Ctrl + B
or ⌘ + K
and ⌘ + B
on Mac OS.
Duplicate lines
Though being DRY is a very good software practice, you may have had to copy and paste a line of code/text numerous times when working on a project.
For this, the combination of the following keys will make your life easier. Hit Ctrl + Shift + D
(Duplicate line) then Ctrl + X
(Cut) and Ctrl + V
(Paste) or ⌘ + ⇧ + D
(Duplicate Line) then ⌘ + X
(Cut) and ⌘ + V
(Paste).
Goto line number
Error reporters or loggers always direct you to a specific line number in any given file. Hit Ctrl + G
or ^ + G
on Mac OS to goto any given line number. Use this in combination with the Open any file shortcut to open a file in your Sublime Text workspace.
Multiple cursors
This feature has been the a major selling point of Sublime Text*. I do believe it’s the first thing you see when you are on the sublimetext.com site.
First select any given word or words you’d like to edit. Then hit the Ctrl + D
or ⌘ + D
to select occurrence of the selected word one by one. You can also hit Alt + F3
or ⌃ + ⌘ + G
to select all occurrences of the word in a given file.
Spell Check
Authors, bloggers, tech writers and programmers interact with text for documentation and code. One big feature they forget to turn on in Sublime Text is using spell check. Make less typos when fixing your code or documentation.
Hit function F6
to toggle spell check in Sublime Text.
Do Anything [BONUS]
Added bonus from reddit user /u/LightShadow. You can do literally anything by hitting Ctrl + Shift + P
. This opens the command pallete or a autocomplete like dialog that allows you to type or do anything in Sublime Text.
Useful packages to install
Working as a python developer, I have found the following Sublime Text plugins the most useful.
- Sublime Linter: For your linting needs. Configure once and forget. This allows you to do static code analysis on most languages. Works really well for python.
- editorconfig: Another gem that will take care if configured correctly to delete any trailing lines, inserting final new line to any given file, picking tabs or spaces when editing and more. This will run each time you save a file in Sublime Text.
- Mark down: For when you would like to preview your markdown files as you are writing them.
Here’s the summary of shortcut keys if you prefer to print it out this section as a cheat sheet.
Sublime Text Shortcut Commands | Mac OS | Windows/Linux |
---|---|---|
Goto Anywhere | ⌘ + R |
Ctrl + R |
Open any file | ⌘ + P |
Ctrl + P |
Show/Hide sidebar | ⌘ + K and ⌘ + B |
Ctrl + K and Ctrl + B |
Duplicate lines | ⌘ + ⇧ + D (Duplicate Lines), ⌘ + X (Cut) and ⌘ + V (Paste) |
Ctrl + Shift + D (Duplicate line), Ctrl + X (Cut) and Ctrl + V |
Goto line number | ⌘ + G |
Ctrl + G |
Multiple cursors | ⌘ + D |
Ctrl + D |
Spell check | F6 |
F6 |
Do Anything | Ctrl + Shift + P |
Ctrl + Shift + P |
* I base this claim on no research evidence, just pure instinct
I am writing a book!
While I do appreciate you reading my blog posts, I would like to draw your attention to another project of mine. I have slowly begun to write a book on how to build web scrapers with python. I go over topics on how to start with scrapy and end with building large scale automated scraping systems.
If you are looking to build web scrapers at scale or just receiving more anecdotes on python then please signup to the email list below.