Sublime Text 2 is one of the best editor for text, code, markup and prose which is available for $59 on OSX, Windows and Linux.
This cheatsheet is based on the Tuts+ online training by Jeffrey Way an editor fanatic who tried them all : Coda, TextMate, Vim.
Installation on Ubuntu or Elementary OS
Sublime Text 3 is in the works, still in beta. In the meantime you can install version 2.0.2, from a terminal:
sudo add-apt-repository ppa:webupd8team/sublime-text-2
sudo apt-get update
sudo apt-get install sublime-text
But if you prefer you can download Sublime-Text2.0.2-x64.tar.bz2
from Sublime Text official site, Windows or OSX binaries are also there.
Killer features
Crtl + Shift + p
Command Palette to limit mouse interactionCrtl + D
Multiple Cursors- Vintage Mode (Vim emulation).
- Lightning fast.
- Become the cool kids code editor, massive documentation.
- Plugin community incredibility vibrant, package control allow you to install them in seconds.
Howto
Shortcuts
Most Used | |
---|---|
Crtl + p |
File palet |
Crtl + Shift + p |
Command Palette |
Crtl + k + Crtl b |
toggle Sidebar on/off |
Crtl + g |
goto line |
Crtl + Shift + Up/Down |
move line up/down |
Crtl + [ or Crtl + ] |
ident back and forth |
Crtl +/- |
zoom in/out |
Multiple Selection / Cursors | |
---|---|
Right Click + Shift |
column selection, use Crtl/Alt to add/remove from selection |
Crtl + D |
add the next occurrence of the current word to the selection |
Crtl + Shift + L |
Select a block of lines, and then split it into many selections, one per line |
Alt + F3 |
select all occurence of the current word |
Bookmarks | |
---|---|
Crtl + F2 |
toggle |
Crtl + Shift + F2 |
clear all |
F2 |
next |
shift + F2 |
previous |
Others | |
---|---|
Crtl + l |
Select line |
Crtl + Shift + i |
Incremental search |
Crtl + Shift + k |
Kill line |
Crtl + Return |
Return like if you were at end of line |
Crtl + / |
Comment line |
Rails tips & tricks
Install ERB Insert and Toggle Commands using Package Control, it gives you easy access to ERb tags, you just need to add the following to your user key bindings after installation to cycle thru Erb Tags with a simple key press:
[
{ "keys": ["ctrl+="], "command": "erb" }
]
Install RubyTest to run your Ruby tests from within Sublime Text 2 just by typing ctrl+shift+t.
See Michael Hartl docs on GitHub for more information.
Package Control
Sublime Package Control is a package manager to discover, install, update and remove packages for Sublime Text 2. It features an automatic upgrader and supports GitHub, BitBucket and a full channel/repository system. To install it follow this procedure :
-
Open Sublime Text console with `crtl + ``
-
Copy the following line to Sublime Text Console
import urllib2,os; pf='Package Control.sublime-package'; ipp=sublime.installed_packages_path(); os.makedirs(ipp) if not os.path.exists(ipp) else None; urllib2.install_opener(urllib2.build_opener(urllib2.ProxyHandler())); open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read()); print 'Please restart Sublime Text to finish installation'
-
If you get
urllib2.URLError: <urlopen error [Errno -2] Name or service not known>
, you may have a bad proxy settings, remove it by adding the following Python line in the above scriptos.environ['http_proxy']='';
-
Restart Sublime Text
-
Launch the Command Palet with
Shift + Control + P
and search for Package Control, you should get the following :
Note: If you type install
in the Command Palet, you can easily install new packages. If you get no package, check your proxy settings or remove them with
gconftool -R /system/http_proxy
If Package Control install fails silently, just remove the Package settings > Package control: user
repositories you’ve configured.
Packages
PlainTasks
This package offers a great way to manage your tasks as plain text files.
Shortcuts | |
---|---|
*Crtl + shift + p / type task* |
Start a new todo-list from Command Palet |
*Crtl + enter* |
New task |
*Crtl + d* |
Toggle done/undone |
*Crtl + m* |
Toggle cancelled |
*Crtl + shift + A* |
Archive all done tasks |
*Project:* |
Anything that ends with : is a Projet |
*@feature* |
Tags |
*- - + tab* |
- - - ✄ - - |
*Crtl + Shit + up/down* |
Re-order tasks |
*Crtl + r* |
List of project |
If you use DropBox and TaskPaper for iOS, you’ll be able to sync up your task to all your devices using the following PlainTask Configuration update :
"open_tasks_bullet": "-",
"done_tasks_bullet": "-",
"date_format": "(%Y-%m-%d)",
"translate_tabs_to_spaces": false,
Following Patch applied, for full TaskPaper compatibility.
FindKeyConflicts
Sometimes you press a key and the result surprise you, it’s maybe due to a binding conflict. The last settings always preval. To check for that you can use FindKeyConflicts Package.
Chef
If you are like me and are interested in Chef, a configuration management framework. You can install the Chef package that will add autocompletion for common Chef idioms.
Customization
My favorite color schemes for MultiMarkdown
- Twilight : white text, brown titles, yellow bullets
- Sunburst : big brown line for Headings
- Monokai : Default one but not enough colorized details for MMD
Note : Solarized Dark and Light are the most popular ones following scientist studies that consider the best lighting for the night and the one the day.
Keyboard troubleshooting
Running Sublime Text 2 under VMware Fusion can sometimes be troublesome when it comes to Key bindings. To see what keys sublime gets from the OS, open the Python console from the View > Console
menu and type
sublime.log_input(True)