Sublime Text used to be a good code editor for many languages and for many programmers. There are many better ones these days but I still use it for quickly modify a file which doesn’t exist in any working project. Here are some Sublime Text tips that I use daily:
All hotkeys below are for Windows. For Mac users, just replace
Split window for a file
Many files contain thousands lines of codes. Sometimes a task required to have different lines be compared or edited at the same time. That’s why we need to view different parts of the same file with clone or split view.
File > New View into File
View > Layout > Columns: 2or
- Drag a tab to other view
Browse a file by name
The editor provides a shortcut which allows you to find a file inside your working directory and you know the name of that file.
Ctrl + P
This hotkey open a popup where you can type in a part of a file’s name to search for it.
Show unsaved changes
You can right-click on an opening file then click on
Show Unsaved Changes... to reveal recently changes which haven’t been saved.
Input a HTML tag
Alt + Shift + W you can place an tag with both opening and closing syntax. By default it places
p tag, but you can type in any HTML tags you want to replace it.
To wrap a block of text with a tag, you can highlight that block and press
Alt + Shift + W.
Search within entire project
Finding a file is something we already know, but Sublime Text make it better with the ability to search an entire project folder.
Ctrl + Shift + F to open the search box. You can input any directory to search within it.
Duplicate current line
You can place the mouse cursor on a line then press
Ctrl + Shift + D. This action will copy the entire current line and duplicate it below.
Move line up or down
Moving lines of codes around with copy and paste is slow. That’s why Sublime Text provides us a shortcut to shift a line up or down.
Ctrl + Shift + Up for moving up a line.
Ctrl + Shift + Down for moving down a line.
Delete current line
Sublime Text also has a method for deleting the entire current line, even if nothing is highlighted.
Ctrl + Shift + K
I have a habit of pressing
Ctrl + S every line of code written. If you are like me, using this feature will help a lot.
Preferences > Settings and add this line:
Best Sublime Text Plugins
- Package Control – This is the must-have package as it helps in installing, downloading and updating of other plugins.
- Alignment – This package takes your code and aligns the configured characters vertically. It is a nice tool to align characters like
(for array in language like PHP.
- Emmet – Emmet is a plugin for many popular text editors which greatly improves HTML & CSS workflow. It turn ul#menu>li*2 into
<ul id="menu"> <li></li> <li></li> </ul>
- SublimeLinter – SublimeLinter is a plugin for Sublime Text that provides a framework for linting code.
- SASS – This is SCSS and Sass syntax, including completions for CSS properties and values, as well as relevant Sass functions.
- GhostText – Everything you type in the editor will be instantly updated in the browser (and vice versa). It is a real time-saver.
- SublimeGit – If you’re used to Git and dealing with Sublime Text packages, you can probably just install SublimeGit, and get right to work.
- SideBarEnhancements – It provides enhancements to the operations on Sidebar of Files and Folders.