Sublime Text: Tips, Plugins

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:

9 Sublime Text Tips

All hotkeys below are for Windows. For Mac users, just replace Ctrl with Command.

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: 2 or Rows: 2
  • 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

With 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.

Press 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

Auto save

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.

Open Preferences > Settings and add this line:

"save_on_focus_lost": true

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.
  • Babel – It provides language definitions for ES6+ JavaScript with the extensions of React JSX syntax.
  • 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.
  • DocBlockr – This package helps writing documentation and simplify writing DocBlock comments in Javascript, PHP, CoffeeScript, Actionscript, C & C++.
  • SideBarEnhancements – It provides enhancements to the operations on Sidebar of Files and Folders.
  • Minifier – Minifier supports Google Closure Compiler for Javascript minification and cssminifier or Reducisaurus for CSS minification.

Sublime Text Hotkeys

Editing 
Cut lineCut line
Insert line afterCtrl + Backspace
Insert line beforeCtrl + Shift + Backspace
Move line/selection upCtrl + Shift + ArrowUp
Move line/selection downCtrl + Shift + ArrowDown
Select line – Repeat to select next linesCtrl + L
Select word – Repeat select others occurrencesCtrl + D
Jump to closing parentheses Repeat to jump to opening parenthesesCtrl + M
Select all contents of the current parenthesesCtrl + Shift + M
Delete LineCtrl + Shift + K
Delete from cursor to end of lineCtrl + KK
Delete from cursor to start of lineCtrl + K + ⌫
Indent current line(s)Ctrl + ]
Un-indent current line(s)Ctrl + [
Duplicate line(s)Ctrl + Shift + D
Join line below to the end of the current lineCtrl + J
Comment/un-comment current lineCtrl + /
Block comment current selectionCtrl + Shift + /
Redo, or repeat last keyboard shortcut commandCtrl + Y
Paste and indent correctlyCtrl + Shift + V
Select next auto-complete suggestionCtrl + Space
soft undo; jumps to your last change before undoing change when repeatedCtrl + U
Wrap Selection in html tagAlt + Shift + W
Close current html tagAlt + .
Column selection upCtrl + Alt + Up
Column selection downCtrl + Alt + Down
Navigation/Goto Anywhere
Quick-open files by nameCtrl + P
Goto symbolCtrl + R
Goto word in current fileCtrl + ;
Goto line in current fileCtrl + G
General 
Command promptCtrl + Shift + P
Toggle side barCtrl + KB
Show scope in status barCtrl + Shift + Alt + P
Find/Replace 
FindCtrl + F
ReplaceCtrl + H
Find in filesCtrl + Shift + F
Tabs 
Open last closed tabCtrl + Shift + t
Cycle up through tabsCtrl + PgUp
Cycle down through tabsCtrl + PgDn
Find in filesCtrl + Tab
Close current tabCtrl + W
Switch to tab number [NUM] where [NUM] <= number of tabsAlt + [NUM]
Split window 
Revert view to single columnAlt + Shift + 1
Split view into two columnsAlt + Shift + 2
Split view into three columnsAlt + Shift + 3
Split view into four columnsAlt + Shift + 4
Set view to grid (4 groups)Alt + Shift + 5
Split view into two rowsAlt + Shift + 8
Jump to group where num is 1-4Ctrl + [NUM]
Move file to specified group where num is 1-4Ctrl + Shift + [NUM]
Bookmarks 
Toggle bookmarkCtrl + F2
Next bookmarkF2
Previous bookmarkShift + F2
Clear bookmarksCtrl + Shift + F2
Text manipulation
Transform to UppercaseCtrl + KU
Transform to LowercaseCtrl + KL

Leave a Comment

Your email address will not be published. Required fields are marked *

By continuing to use the site, you agree to the use of cookies. more information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.

Close