Sublime Text 2 Tips and Tricks (Updated)

Sublime Text 2 Tips and Tricks (Updated)

Tutorial Details
  • Editor: Sublime 2
  • Availability: OSX, Linux, Windows

Sublime Text 2 is one of the fastest and most incredible code editors to be released in a long time! With a community and plugin ecosystem as passionate as this one, it just might be impossible for any other editor to catch up. I’ll show you my favorite tips and tricks today.

Sublime Text 2 is currently available for all major platforms: OS X, Linux and Windows.


1 – Bleeding Edge Versions

Sublime is in active development. If, like me, you want to use the latest possible version of the app, you can download the dev build. You’ll find that new (auto) updates are available every other day or so.

Download a dev build of Sublime 2 here.


2 – Get a Better Icon

Update: here is a better icon.

In its defense, Sublime Text 2 is still in a beta state. The official icon will likely/hopefully change with the official release. Until then, Nate Beaty created an alternative icon, if you prefer it.

To integrate it, you need to replace the existing “Sublime Text 2.icns” file with this new one. On a Mac, browse to Sublime 2 in your Applications/ folder, then right-click and “View Package Contents.” Lastly, browse to Contents/Resources/, and drag the new icon in, overwriting the existing one.

Please take note of the fact that, if you’re using the frequently updated development version of Sublime Text, with each update, the icon will be removed. With that in mind, don’t worry about the icon for the time being.


3 – Access the Command Palette

Similar to TextMate, we can use Sublime’s command palette by accessing the Tools menu, or by pressing Shift + Command + P, on the Mac. Whether you need to visit a Preferences page, or paste in a snippet, all of that can be accomplished here.

Access the command palette

4 – Lightning-Fast File Switching

File Switching

Press Control or Command + P, type in the name of the file you wish to access (fuzzy finder), and, without even pressing Enter, you’ll instantly be transported to that file. While Vim and apps like PeepOpen offer a similar functionality, they’re not nearly as fast as Sublime’s implementation.


5 – How Did We Survive Before Multi-Selection?

Editors like TextMate have long offered vertical selection, which is quite neat. But, with multi-selection, you can have multiple cursors on the page. This can drastically reduce the need for using regular expressions, and advanced search and replace queries. Perhaps a quick visual demonstration is in order…

To enable multi-selection, you have several options:

  • Press Alt or Command and then click in each region where you require a cursor.
  • Select a block of lines, and then press Shift + Command + L.
  • Place the cursor over a particular word, and press Control/Command + D repeatedly to select additional occurrences of that word.
  • Alternatively, add an additional cursor at all occurrences of a word by typing Alt+F3 on Windows, or Ctrl+Command+G on the Mac. Amazing!!

6 – Indent Guides

Update: this feature now comes preinstalled with Sublime Text 2.

It’s such a small feature, but I’ve always loved how Notepad++ on Windows displays indent guides; it makes the page much easier to navigate and format. Sublime Text 2 offers this ability, via a plugin created by Nikolaus Wittenstein.

Indent Guides

To integrate this plugin:

  • Download it
  • Rename the folder to “Indent Guides” and drag it into the Packages folder. On a Mac, this path would be Application Support/Sublime Text 2/Packages

7 – Package Control

The steps outlined in the previous tip (#6) are a bit tedious, aren’t they? Instead, we can install the excellent Sublime Package Control, which streamlines the entire process.

To install “Package Control,” open Sublime and press Control + `. Next, paste the following snippet into the 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;open(os.path.join(ipp,pf),'wb').write(urllib2.urlopen('http://sublime.wbond.net/'+pf.replace(' ','%20')).read())

Don’t worry if you don’t understand the code above; just copy and paste!

Console

Lastly, restart Sublime Text, and browse to Preferences -> Package Settings. If the installation was successful, you’ll now see a Package Control item in that list.

With Package Control installed, the process of adding new plugins and functionality becomes incredibly simple!

For a usage example, refer to the next item in this list.


8 – Alignment

If you’re the type who prefers to line up your equal signs – for example, in your JavaScript…

// Before  
var joe = 'joe'; 
var johnny = 'johnny'; 
var quaid = 'quaid';

// After
var joe    = 'joe';
var johnny = 'johnny';
var quaid  = 'quaid';

…this process can be automated, via the Sublime Alignment plugin. Rather than downloading and installing it manually, let’s instead use Package Control (outlined in #7).

  • Press Shift + Command + P
  • Type “install,” to bring up the “Package Control: Install Package” option, and press Enter
  • Look for “Alignment,” and press Enter to install it.
  • You’re done; so easy! Type Shift + Command + A to auto-align.
Auto-align

This process can be repeated for all of the typical plugins we install, such as Zen Coding.


9 – Vim Fanatic

I’m a huge fan of Vim. The amount of power it provides is insane. The fact that I’ve switched over to Sublime Text 2 should speak volumes then!

If you’re using a dev build of Sublime Text (see #2 in this list), you can enable Vintage mode, which provides support for the Vi commands that we know and love — okay…some of us love. The rest of you hate it! :)

To enable Vintage mode, browse to Preferences/Global Settings - Default. Once this file opens, browse to the very bottom, and change "ignored_packages": ["Vintage"] to "ignored_packages": []. Next, restart Sublime, press the Escape key, and, tada: command mode!

Block Cursor

One thing you may notice is that, in command mode, it can be difficult to find the cursor (especially when taking advantage of things like bookmarks). On more than one occasion, I’ve found myself trying to hunt down its location.

While it’s not a perfect solution, a plugin, called “SublimeBlockCursor,” attempts to remedy this issue.

Note: While the readme states that SublimeBlockCursor can be installed, via Package Control, I wasn’t able to find it. Instead, I had to clone the project manually into the Packages folder.


10 – Distraction Free Editing

Sometimes, we need to filter out all of the additional fluff that gets in the way of our coding. Use “Distraction Free Mode” to take this idea as far as possible. This option is available, via the View menu. Select “Enter Distraction Free Mode,” or use the Mac keyboard shortcut, Control + Shift + Command + F.

Distraction Free Mode

11 – You Can Still Use TextMate Bundles

Slim

TextMate snippets and themes port over nicely to Sublime Text. You only need to drop them in the Packages folder — .tmbundle extension intact, and Sublime will recognize the files. This means that the entire catalog of TextMate themes will work in Sublime!

For example, I’ve been working with the (fantastic) Slim templating engine a good bit lately, and needed better syntax highlighting. Fred Wu created a bundle for TextMate, but, tada, it works perfectly in Sublime Text as well! If you’re interested, you can download the Slim bundle here; it includes both snippets and syntax highlighting.


12 – Custom Themes

The default theme for Sublime Text is excellent, but I much prefer a custom light and dark theme, Soda, created by Ian Hill.

Soda Theme

Installation

As taken from the Github page…

“If you are a git user, the best way to install the theme and keep up to date is to clone the repo directly into your Packages directory in the Sublime Text 2 application settings area.”

Using Git

Go to your Sublime Text 2 Packages directory and clone the theme repository using the command below:

 git clone https://github.com/buymeasoda/soda-theme/ "Theme - Soda"

Download Manually

  • Download the files using the GitHub .zip download option.
  • Unzip the files and rename the folder to Theme – Soda
  • Copy the folder to your Sublime Text 2 Packages directory

Activating the Theme

To configure Sublime Text 2 to use the theme:

  • Open your Sublime Text 2 User Global Preferences file: Sublime Text 2 -> Preferences -> User Global Settings
  • Add (or update) your theme entry to be “theme”: “Soda Light.sublime-theme” or “theme”: “Soda Dark.sublime-theme”

Example User Global Settings

{
    "theme": "Soda Light.sublime-theme"
}

13 – Page Crawling

Sublime Text provides us with a few different ways to query a page (outside of the standard search functions).

Functions

Need a quick way to browse to a specific function or method?

Function Crawling

Type Control/Command + r to reveal a popup that allows for this very thing (notice the @ symbol)! Even better, the search is fuzzy as well, which is particularly helpful for huge classes.

HTML

What if you want to immediately transition to a specific part of an HTML page – say, to the div with a class of container. Type Control/Command + p, then #, and you’ll instantly see a tree of your document.

Go to Line Number

To quickly move to a specific line number on the page, you can press Control + g. However, you’ll notice that, once again, it’s pulling up that palette (Control/Command + p), and appending the : symbol. This is adopted from Vim.

This means, in addition to Control + g, you can also type, Control/Command + p, and then :LINE_NUMBER.


14 – Fetch Remote Files With Ease

Nettuts+ Fetch

Let’s say that you’re a fan of Normalize.css. Perhaps, you download it and save it to a snippet, or store the stylesheet, itself, in an assets folder. That way, for future projects, you only need to copy and paste.

The only problem with this method – as we’ve all discovered – is that, if a few months have passed, it’s more than possible that the asset (in this case, Normalize.css) will have been updated by the creator. So your options are to either use the, now, out-dated version of Normalize, or, once again, return to the GitHub page and pull in a fresh copy. This all seems tedious.

Created by Weslly Honorato, Nettuts+ Fetch is the solution to our dilemma. It can be installed, via Package Control.

Usage

You’ll only use two commands, when working with Fetch. First, we need to save some file references. Again, bring up the command palette, and search for “Fetch.” For now, choose “Manage Remote Files.”

Manage Remote Files

What’s great about Sublime Text 2 is that configuration is incredibly simple. To assign references to online asset files, we only need to create an object, like so (don’t worry; one will be pre-populated for you, after installation):

So, to pull in the latest copy of jQuery (if you don’t want to use a CDN):

{
	"files":
	{
		"jquery": "http://code.jquery.com/jquery.min.js"
	}
}

Learn more about using Nettuts+ Fetch.


15 – Prefixr Plugin

Built by by Will Bond (creator of Package Control), the Nettuts+ Prefixr plugin allows you to automatically update your entire stylesheet to include support for all of the various required CSS3 vendor prefixes. This way, you never have to visit the website itself; you merely type a keyboard command, and:

.box {
   border-radius: 10px;
   box-shadow: 0 0 5px rgba(0,0,0,.4);
}

…will be converted to:

.box {
	-webkit-border-radius: 10px;
	-moz-border-radius: 10px;
	border-radius: 10px;

	-webkit-box-shadow: 0 0 5px rgba(0,0,0,.4);
	-moz-box-shadow: 0 0 5px rgba(0,0,0,.4);
	box-shadow: 0 0 5px rgba(0,0,0,.4);
}

Usage

Once installed (via Package Control), select your stylesheet (or a single block), press ctrl+alt+x on Windows and Linux, or cmd+ctrl+x on OS X, and the code will instantly be run through the Prefixr web service.


16 – Launch Sublime From the Terminal

Sublime Text 2 includes a command line tool, subl, to work with files on the command line.”

To use it, create a symlink to the tool.

ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" ~/bin/subl

As long as ~/bin is in your path, that should do the trick!

cd myProject
subl .

Refer here for additional instructions.


17 – Autoformat HTML

A bit oddly, the ability to auto-format HTML is not included as part of the default build of Sublime Text. The Tag plugin, among other things, hopes to provide a solution, however, due to a few shortcomings – namely when dealing with HTML comments – it falls short.

The Tag plugin can be installed via Package Control.

To test its auto-formatting skills, the following HTML:

<html>
<head>
	<meta charset=utf8>
	<title></title>
	<!-- begin-->

	<!-- end comment -->
</head>
<body>

<h1>Hi there</h1>

<h2>Bye</h2>
</body>
</html>

…will be changed to:

<html>
	<head>
		<meta charset=utf8>
		<title></title><!-- begin-->
<!-- end comment -->
	</head>
	<body><h1>Hi there</h1>

		<h2>Bye</h2>
	</body>
</html>

Yikes; it looks worse than it is. From my tests, it incorrectly does not place the body tag on its own line, and gets pissy when dealing with HTML comments. Until these issues are fixed (or a native solution is provided), it’s best to manually select a block of HTML to reformat, rather than the entire page.

A $200 bonus will be paid to the first Sublime Text plugin developer who creates and submits the definitive “Nettuts+ HTML Formatter” plugin.


18 – Create a Plugin

If you’re feeling adventurous, dig into Sublime Text’s huge plugin development community, and start contributing. We have an excellent tutorial on the process of building a ST plugin here on Nettuts+. Be sure to check it out if that interests you!


Conclusion

The more I work with Sublime Text 2, the more I realize how incredible it is. But all of this would mean nothing if not for the fact that it’s an insanely fast editor, and, even better, it’s not finished!

Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.sunabr.com Axel Grazx

    Hi! Today is my second day using Sublime, and it fells great… I’m also a huge fan of development in Dreamweaver and there is a feature in special that I wonder if is available in Sublime: the class/id auto-complete…

    It get all the CSS’s classes and id’s and when you’re about to use it (ex. <div class="…) give you a list of the ones of the css file attached.

    Sublime can do it?

    • http://levifig.com Levi Figueira

      In all honesty, you should be developing the other way around: you set tags in HTML and *then* style them in CSS…

      • http://www.dreamchain.com Simon

        What Alex Grazx is asking for makes sense to me. It has to do with keeping your code DRY. You don’t want to individually style every element, you would want to reuse styles from your existing style sheet.

    • Ngoc Duy

      You use plugin Zen coding…

  • peter

    Hi! I have a question about creating new files in ST2 like Jeff on his “Jquery in 30 days” course in lesson 4. You make right click on the folder name in sidebar and choose “New file” and then input (at the bottom) where you can type a name of new file appears. I’m curious is it plugin or just a setting? It’s really handy and I want it to set up in my editor. Thanks in advance!

    • Johannes

      I’d really like to know that too. I have messed around with Sublime’s settings and I got really basic and pretty useless sidebar, you can change between open files and close them. I have done some Google research on that but nothing so far. Does someone know how to get that result?

      • webwesen

        add a folder to you project – it will show up in the sidebar (Project -> Add Folder…)

      • Michiel

        I think you mean the SideBarEnhancements plugin.

      • peter

        I managed to find a plugin and this is SideBarEnhancements like Michiel said. It’s great and give a lot of options i.e. Open With (you can set up any app i.e. Firefox or Chrome).

        But it would be much better if this worked with CTRL+N instead of Right Click -> New file, but it’s very handy anyway ;)

      • ZeljkoSI

        Like webwesen said, add a project folder and you can create new files with right click -> new, you don’t need a sidebar plugin.

      • e_dub

        Hey guys, there’s a killer package called Quick File Creator that does what I believe you guys are looking for, and what’s more, it also gives you the ability to quickly add whole Folders as well.

    • e_dub

      Forgot to mention , it has keyboard shortcuts for this: ctrl + super + n, and ctrl +super + d respectively, though you might have to add these to your user keybindings by hand. The read me provides the correct formatting, just add cut and paste them from the read-me file into the user-keybindings file (available from the preferences menu). Make sure to place them between brackets, and that there is a comma between each keybinding you add (but no comma after the last one).

      In fact, a good tip, open up the package browser, go through your packages and read the read-me files. MANY of them have additional features/options you can set, or keybindings you can create, adding a great deal of function to ST2. Just be sure to create a cheat-sheet file and keep track of any shortcuts you create. This way you don’t add/learn of a bunch only to promptly forget them, and have no reference to go back to when you need them.

  • http://binaryhop.com Bill

    @Axel Grazx

    ctrl+space works for the linked css, but not just css unfortunately. So if you know the first letter or two for the class or id it works alright then.

    Still learning how to use Sublime myself. :)

  • http://www.cronowebmasters.com/ cronowebmasters

    It doesn’t even have the code autocompletition for PHP (ctrl+space). I run the program for about 5 minutes. I think that it’s the same as Notepad++.

    • Ivan

      There is a little plugin called SublimeCodeIntel; it comes with all the autocompletion you need for PHP and other languages; and there is another plugin called SublimeLint to check for syntax errors (in PHP and many other languages)

  • Igor

    Beautiful, but inefficient for PHP (from my point of view). No autocompletion.

    • e_dub

      There’s plugins for that. You need to check out the package manager as it suggests in the article, and look through the tons of available plugins. There are legions of them for PHP.

  • Juan

    Hi there!

    I have a question about how to turn off parenthesis matching for editing clojure file???

    eachtime I type ( will become ()

    which is good for text editing. But annoying for editing clojure files.

    Thanks a lot!

    • Nathan

      Try running emacs myproj.clj from your terminal :)

  • Ashfaq

    hi

    can you repeat step 7 for control package, coz i didn’t get what to press with contro [control + ?] plz

    • http://www.gowthamn.com Gowtham

      @Ashfaq The keybind for launching Python console is “Ctrl + `” (Control + Backquote). After you open the console, copy-paste the python code in the interactive console.

    • http://piksel.se piksel

      or [control + ö] on a swedish keyboard, it depends on your keyboard layout.

      • http://why.com S

        Tackar, tackar!
        I never found that shortcut so I’ve been remapping it. Now I can use the default.

  • Juan

    Anyone know what happened to vertical selection? Since the latest beta update, I haven’t been able to select text vertically on my macbook, Alt+click just pops up the right click menu. At least, I think it was alt-click. No matter what key combo I tried, I couldn’t get vertical selection to work. (Keep in mind, I’m not referring to clicking and dragging down the gutter and selecting entire lines.)

    • http://www.gowthamn.com Gowtham

      Works for me as of 3/13/2012 and I downloaded the latest build just now.

  • http://concordia.duvieusart.net Nicolas

    I’m using Vintage mode on OS X 1.07 and pressing & holding the “j” key only go down one line.. it does not keep going.. Anyone know how to change that ?

    • http://ngocpham.info/ Ngoc Pham

      You should run this command in the Terminal:

      defaults write -g ApplePressAndHoldEnabled -bool false

  • http://hellomynameisjuan.com kilinkis

    my mate at the office been using it for a while, now im trying it out, i really love that it has the VIM keys (L) xD!

  • Rajat

    I’m using sublme text 2 build 2181 I want to know if there is plugin which autocapitalse first letter of words.Please let me know

  • Patrice

    I just tried the Tag package, and it didn’t manage to format my HTML source correctly.
    It doesn’t seem to like nested tables that much.

    Other than that, I’ve been using Sublime Text for some weeks and don’t plan on using any other editor, I really love it.

    • Patrice

      I must confess, there was a mistake I did not see in my source, the Tag plugin is innocent and works fine.

  • Colin

    Great stuff. Thank you!

  • http://www.sebastianscaramuzza.com/ Sebastian Scaramuzza

    Great Software and Great Article!!! :-)

    I just want to report a mistake on the 5th trick. You wrote:

    «Press Alt or Command and then click in each region where you require a cursor.»

    But for Windows users is CTRL, not Alt!!!

    Hiiiiii!

    • Tamás Barta

      Also, for Linux users (Ubuntu), since Alt+Mouse1 is usually used to move windows.

  • http://mystrd.at mystrdat

    #7, #16 – I smell the classy Pimpzilla scrollbars. Well played, Jeffrey. Well played indeed.

  • Ken

    Url handler for xdebug file link in ubuntu
    https://gist.github.com/2037205

  • http://www.istudio.com.mx Alfredo Ramirez

    Very powerful editor and excellent UI workspace, thanks for the tips and tricks!!

  • juan

    Hi, thank you for great tutorial…

    I have a question on snippet.

    I create my own snippet. Called group.sublime-snippet save in where it should resides.


    grep

    source.rb

    I set the scope to .rb files, but the trigger (type grep, press tab) does not work in any .rb files. (I’ve restarted my sublime text2).

    Any tips??

  • Abdel

    Hi there,

    After watching JQuery in 30 days Jeffrey way’s videos I just liked the Sublime Text 2 the way he used it and how fast it reacted.

    So quickly I got it, installed it, and started to struggle! spent hours now trying to figure out how can I set it up exactly like his on the video…apparently it’s worse than Coda without third party plugins! Alignment doesn’t work with shortcut..zenCoding doesn’t work either..I installed it so many times and there is absolutely no documentation of how to use it with ST2! forum is very weak also..

    it is definitely NOT out of the box editor for that price!

    I noticed also many limitations and bugs i.e the auto complete is limited to work with a file format, which means if you are coding in HTML it works, but as soon as you type inline CSS code it doesn’t trigger the auto-complete!

    Guys if I am missing something please explain and advise me! otherwise I am still and will be convinced that Dreamweaver is the most reliable code editor out there.

    Thanks
    A

    • http://andrewhainen.com Andrew

      Take a look at your computer processes and RAM usage when you have Dreamweaver open, and then take a look at it with Sublime Text 2 open. You should probably see a significant difference, and all your doing is editing text. Dreamweaver comes with MOUNTAINS of crap you don’t need. I use Coda, and the new one is less than great. Sublime seems much more barebones, not as user friendly right away, but once you write more, most people just want the editor to get out of the way and be lightning fast – which Sublime is and Dreamweaver is not.

    • rhet

      Try to install this package https://github.com/Kronuz/SublimeCodeIntel

  • http://www.progwd.net Mohammed Fellak

    very good
    tips and tricks

    but there is a problem in the software witch i download it from sublimtext.com
    for windows 32

  • http://www.clippingimagesonline.com Asif

    I love comment to tutorial

  • http://www.g-raph.be G-raph!

    Thx a lot!!

  • http://netpro2k.com netpro2k

    Just a quick note, I have fixed the issue causing SublimeBlockCursor not to show in Package Control. You should now be able to install it directly from within sublimetext.

  • Jon

    I’ve just downloaded ST2 and I have to say all these features seem great.

    I installed Package Control and then attempted to install the Sublime Block Cursor plugin. It’s installed and I can see it in my folders, but I’m not seeing any block cursor in the editor? I’ve restarted the app but still nothing.

    Am i missing any steps?

    • http://netpro2k.com netpro2k

      SublimeBlockCursor only works when using Vintage (and only when in command mode). Do you have vintage mode enabled?

  • Siros

    Nice tips and Great Editor !

    Vinage Mode is getting better and better as more commands are added.

    by the way , I keep getting back to Vim after 5 mins of using ST2.

    And I don’t think that any one would leave vim , unless he wasn’t comfortable with it.

  • Mohammed

    Perfect App!
    But I wanted only more feature:
    displaying multiple code coloring at the same time, for example, HTML with CSS & JavaScript would be perfect.
    Others may find PHP & HTML more important.
    Any way, this addition will make me very satisfied with this app.

  • http://plicatibu.com Marcio Andrey Oliveira

    How good is the Vim support ?

    I mean, Vim accepts a lot of commands. Is there any limitation in Vintage or does it allow all commands I would be able to type on Vim?

    Thanks.

    • http://myfreakinname.blogspot.com ruffin

      Lots of stuff missing from VIm. You can’t even perform your last search again by hitting “/” followed by return.

      It’s a very limited, though very helpful, subset.

  • http://www.niteshsharma.com nitesh sharma

    please help me to find shortcut/plugin to browse the local dir. for example if img[src=] should open a dialogue to select image.

  • Santhosh

    A quick update: the shortcut for Alignment is Control+Command+A as opposed to Shift+Commad+A (as mentioned in point 8).

    Thank you for a great article.

  • SPeed_FANat1c

    Please tell somebody how to disable that multiple cursor function, because I never used it and it turns on when I click something, when I don’t even want and starts editing code in two places, its counter productive when I later see I am editing in two places and have to delete.

  • Bala

    Errata: Alignment of equal signs is ctrl + cmd + a, not cmd + shift + a

  • http://csstube.ajmlab.com Andrew Milson

    I have to say Sublime Text 2 interface looks great but I miss some of the features of Coda 1. For example I find the file navigator on Coda better because you can navigate through files as if you where on Finder, but on Sublime Text 2 the file navigator is not as good.

    If someone knows how to navigate files more easily on Sublime Text 2 please tell me, it would be much appreciated.

  • http://prashantsahni.in Prashant Sahni

    How should i reach to the method, when in call that method from some other file.

    suppose in file1 i have method test, and in file file 2 i have called the method ‘test’, now how should i know

    the location of the method test, if i am not aware of it location.

    Thanks

  • http://thekaroshiworkshop.com Elliott

    another one is to set a key binding for converting your tabs to spaces. After a bit of Googling, it seems no one has been able to answer it. So, I sincerely hope this makes it into the index and people get to use it:

    { “keys”: ["control+shift+a"], “command”:”expand_tabs” }

    • Brad

      I agree, it’s difficult to find this tidbit. Here’s a link to the doc on this setting: http://www.sublimetext.com/docs/2/indentation.html

      • Brad

        Uh… never mind! I see upon reflection (meaning: careful reading of your post) that you were looking for how to set a key binding, not find the setting or the menu item (under View | Indentation, which run the expand_tabs and unexpand_tabs commands; look for the heading at my link titled, “Converting Between Tabs and Spaces”).

        I assume the unexpand can also be set to a key binding for setting it back, i.e., the reverse.

  • murat

    There is a mistake on 8. part.Instead of “You’re done; so easy! Type Shift + Command + A to auto-align.”
    you must “Make a multi-line selection, or multiple selections
    Press ctrl+alt+a on Windows and Linux, or cmd+ctrl+a on OS X”

  • http://www.kleibernet.de Sascha

    Hi,

    the prefixr-plugin doesn’t work here, unfortunately… :-(

  • moosh

    I’ve been using TextWrangler to write mostly Perl… I’m looking for something a bit better and have been comparing BBEdit vs Coda 2 vs Sublime Text 2.

    Of them all I like Sublime Text 2 as it seems to have the most potential — but I have some questions and was wondering if you could help?

    With TextWrangler I will write the script then “Run from Terminal” and it does it’s thing. I can have many scripts running at the same time, all launched from TextWrangler, all running in separate Terminal windows.

    In Sublime, I launched a “Send Tweets” script (I used “Build Ruby” to execute, as I haven’t seen a Build Perl….) and then while it was running, I opened a new Sublime file and ran it. By running the second script, my Send Tweets script was stopped…. Can it only run 1 thing at a time? Is there a way to run multiple scripts at once? Can it launch them out to terminal, so Terminal does it?

    Also is there a Build Perl module?

    I found that by Build Ruby works, it overlooks what would otherwise be some syntax errors (which TextWrangler flags through “check syntax”) such as not including a “;” at the end of a line….

    I’m very new to programming. Perl is all I know thus far (and love it) and want an environment that can support learning… It’s just that TextWrangler and BBEdit make these things much easier, but lack the auto-complete (as far as I can tell) and some other features that I like about Sublime.

    Thank you.

  • Pinkie B

    I have to say, I think I’m a pretty competent computer user — I have no problem using a command line and I have basic experience in multiple programming languages — but I can’t even get the program to produce a .pdf and none of the online guides make any sense. How about using some *English*? Or providing a dictionary? Or maybe just distributing the program in a way that works?

  • Matt

    In one of Jeffrey’s tutorials he says that he has deleted Sublimes default snippets and added his own snippets to make them easier to remember.
    I followed along and have made some snippets, alot of them work well but a few seem to be getting over ridden by the default snippets.
    Does anyone know how to delete these default snippets?

    Thanks

  • AntoxaGray

    I’m glad it’s still free software.

  • http://www.joomlapro.com.br Bruno Batista

    Is possible to get the file name to include with snippet?

    http://www.sublimetext.com/forum/viewtopic.php?f=2&t=8687

  • http://jefftschwartz.wordpress.com Jeffrey T. Schwartz

    Great article, Jeff. Your passion for VIM convinced me to give it a try. I love it. I also love ST2. So now I’m faced with a quandary every time I need to edit something — which one of these great editors do I use? I’ve got VINTAGE mode turned on in ST2 and it’s like having your cake and eating it too.

    I’m a little bit older than you (OK, a lot older lol) and back in the days of MS DOS my editor and word processing program of choice (not much choice really back in those days) was a program called Word Star which, among other things, had a similar keyboard mode of movement that VIM’s command mode has. When everything turned GUI Word Star was to be no more and I missed it dearly. VIM, in many ways brings back many of those joys that I had when using Word Star, namely never having to take my hands off the keyboard and relying on the home row keys to do 99.99 of the movement I’d need in a document.

    Textmate was a great editor but I fear that now, with its release as OS and hosted on GIT, a version 2 will never see the light of day. Its prolonged state as an Alpha release led me to VIM and to ST2. There’s an expression, “when one door closes another door opens”, and in this case it certainly rings true. There’s also another one, “The King is dead. Long live the King.”

    Thank you for all the great video tutorials and articles. Keep at it.

    Jeff Schwartz

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      Thanks, Jeffrey! Whether you end up with Vim or Sublime Text…there isn’t a wrong choice. Both are fantastic.

  • http://nothing Socks

    Hi guys, great article.

    Anyone knows which is the beautiful color theme in the Indent Guides screenshot?
    It’s amazing!

  • http://thousandfive.com Matt

    Here’s yet another replacement icon more in-line with the current keyboard button look: http://dribbble.com/shots/707233-Alternative-Sublime-Text-2-Icon

  • Macapá

    The item 7 does not works correctly in version 2.0.1..

    You can use this steps instead:

    http://wbond.net/sublime_packages/package_control/installation

    regards

  • jcook

    I’ve been trying ST2 for a few days now and it looks interesting, but I haven’t found the secret build-system incantation required to let ST2 see my PYTHONPATH. I’ve added an “ENV” statement in the build file to no effect. Am I missing something?

  • b00nz00

    I need a plugin that format code like cmd+F in Aptana… Someone know if exist?

    • http://twitter.com/afflicto Afflicto

      Oh yeah. i want that too, I miss that!

  • http://jaygunn.com Jay

    Doing some evaluation of Sublime Text 2 and I’m almost certainly buying it. I love Espresso on my Macs, and I use Notepad++ on Windows because there hasn’t really been anything better (if you don’t count Vim of course… I have not been able to wrap my head around that one, and I just don’t have the time to really dig in and learn it), and Gedit or Kate on Ubuntu. The fact that ST2 is on all platforms is enough for me to buy it now.

    But there’s one thing that I’m trying to figure out if it’s even possible: Multi-selection points with the keyboard only.

    I know you can hold down cmd/alt/super and click points to have multiple selections, but it seems like it would be so much faster if you could hit a shortcut to mark a spot, alt/ctrl+tab to the next word, mark the next spot, repeat until you’ve made your selections and then start typing/making your edits.

    This came to me today when I was trying to sort a comma separated list of city names, and to do that I have to first put each city on it’s own line, select the lines, sort, then re-join the lines. Currently having to alt/cmd+click in front of each city to mark selections because it seems keyboard only multi-select is only in a column and not able to split the selection points on a line, or even over several lines.

    Am I just missing the shortcut to do this, or is there perhaps a plug-in/package available to do this?

  • http://ricardozea.net Ricardo Zea

    To “Autoformat HTML”, you don’t need a package.

    All you need to do is one of three things:

    1. Go to Edit / Line / Reindent = Too frigging long.
    2. Type Alt+E+L+R = Same thing as above and certainly MUCH faster, but 3rd option is even faster.
    3. Type CTRL+SHIFT+R = No need to have the your HTML markup selected

    Now, for #3 you need to create the shortcut since Sublime Text 2 doesn’t come with it for this function. VERY weird if you ask me.

    And creating the shortcut is not difficult at all. It’s also a one-time-step:

    A. Go to Preferences / Key Bindings – User (a blank file will open)
    B. In that file paste the following piece of code:
    [
    { "keys": ["ctrl+shift+r"], “command”: “reindent” , “args”: {“single_line”: false}}
    ]

    NOTE: It doesn’t have to be CTRL+SHIFT+R, just change the keys to whatever you feel comfortable.

    Done :)

    • Ricardo Zea

      Please delete this post since it’s incomplete. Tnx

  • http://ricardozea.net Ricardo Zea

    To “Autoformat HTML”, you don’t need a package.

    All you need to do is one of three things:

    1. Go to Edit / Line / Reindent = Too frigging long.
    2. Type Alt+E+L+R = Same thing as above and certainly MUCH faster, but 3rd option is even faster.
    3. Type CTRL+SHIFT+R = No need to have the your HTML markup selected

    Now, for #3 you need to create the shortcut since Sublime Text 2 doesn’t come with it for this function. VERY weird if you ask me.

    And creating the shortcut is not difficult at all. It’s also a one-time-step:

    A. Go to Preferences / Key Bindings – User (a blank file will open)
    B. In that file paste the following piece of code:
    [
    { "keys": ["ctrl+shift+r"], “command”: “reindent” , “args”: {“single_line”: false}}
    ]

    C. Save and close that file.

    NOTE: It doesn’t have to be CTRL+SHIFT+R, just change the keys to whatever you feel comfortable.

    Done :)

    PS. It’d be nice if Jeffrey decides to update this article with this advice. After trying different “Autoformat HTML” packages, no package indented the markup as clean as this ‘native’ mode, nor any of them was as easy to use as the authors claimed. I search around the web and this solution is used by many, many people. Tnx.

    • http://twitter.com/SaraSoueidan Sara Soueidan

      Thank you for this tip! :)

    • http://www.facebook.com/adrianpauly Adrian Pauly

      Awesome, thanks Ricardo! This will cumulatively save me hours.