In this video article, I’ll be showing you a couple of important Sublime Text Shortcuts. Knowing these shortcuts you’ll be able to code faster as you don’t have to touch the mouse much.
You can use the Sublime Text command palette to perform almost all the tasks that are available in Sublime Text menus. You can open up the Command Palette by pressing Command+Shift+P on Mac and Ctrl+Shift+P on Windows. A keyboard shortcut combination is also displayed in front of the command which has a shortcut associated with it.
You can use this option to navigate to any file in your project without opening the Sidebar or using the mouse. The keyboard shortcut is Command+P on Mac and Ctrl+P on Windows.
Probably the best feature of Sublime Text is Multiple Cursors. You can create multiple cursors by selecting a word and then pressing Command+D on Mac or Ctrl+D on Windows. After multiple cursors have been created you can change the word to all the instances in the open file all at once. You can also press Ctrl+Command+G on the Mac to select all the instances of the selected word at once.
You can use this option to navigate to any defined method/function in your programming script file or CSS selector in a CSS file. You can use this by pressing Command+R on Mac or Ctrl+R on Windows. This will display all the methods or CSS selectors defined in the open file depending on the type of file. Then you can type a couple of letters to search through and pressing Enter will jump directly to its declaration.
Goto Line Number
If you are a fan of line numbers like me, this shortcut will enable you to easily jump to a specific line. Just press Ctrl+G on Mac/Windows and type in the line number to jump to that specific line in your code.
Just like an IDE, we don’t always know which method/function is defined in which file so it’s really handy to have a shortcut that will directly jump to a method/function’s definition wherever it is in your project. Just put your cursor on a function name in your call and then press Command+Shift+DownArrow on Mac or Ctrl+Shift+DownArrow on Windows to directly jump to it’s definition. If sublime text finds that same name defined in multiple files, it’ll open up a popup for you to select the proper file and pressing enter will jump directly to the definition.
Insert Line Before/After
This is also a very handy little shortcut as a lot of times this happens that pressing enter in the middle of the line splits that line instead of inserting a new line before or after depending on what we want. To insert a line before your current line you press the Command+Shift+Enter shortcut or Command+Enter to insert a line after your current line.
If you want to quickly delete the current line, pressing Ctrl+Shift+K on Mac/Windows will delete the current line on which you have your cursor.
You can quickly toggle comments by selecting the lines you want to comment out and using the following keyboard shortcuts. Command+/ on Mac and Ctrl+/ on Windows for Single Line comments and Command+Option+/ on Mac and Ctrl+Alt+/ on Windows for Block Level comments.
If you want to quickly change the change of the selected word, you can press Command+K+U on Mac and Ctrl+K+U on Windows for Uppercase. Command+K+L on Mac and Ctrl+K+L on Windows for Lowercase.
These are some of the important keyboard shortcuts that you can use. A lot of Sublime Text commands have their respective key bindings which you can view from the menu bar or the Command Palette. A few more are mentioned below.
- Duplicate Line (Command+Shift+D on Mac / Ctrl+Shift+D on Windows)
- Move Line Up (Ctrl+Command+UpArrow on Mac)
- Move Line Down (Ctrl+Command+DownArrow on Mac)
That’s it for this tutorial. In the next tutorial I’ll be showing you how to change the appearance of Sublime Text.
Till next time, Good Bye.