Want VIP access? Get the latest tutorials, videos, giveaways and more!

×

5 Helpful Tips for moving to Sublime Text 2

I’m a long time Coda user. A few months ago I, like everyone else, decided to switch over to vim. I really liked Vim but just couldn’t get the hang of it for whatever reason. After shamefully crawling back to Coda, I found myself realizing that Coda fell short in a few areas. It was then I decided to give Sublime Text 2 a shot as it had been touted as the sucessor to Text Mate. Its taken me a few weeks to get used to, but I can happily say I’m a Sublime Text 2 user now. Here are a few tips that make switching over easier.

1. Install the command line utility

Sublime Text 2 Command Line Utility

If you do a lot of work in bash, its helpful to open up a file or entire folder in your editor right from the command line.

To Install:
Run the following line in your terminal.
sudo ln -s "/Applications/Sublime Text 2.app/Contents/SharedSupport/bin/subl" /bin/subl
This will then give you access to the bash command subl with a number of arguments.

The most basic usage is to open the current folder in Sublime Text 2. Simply Type subl .

subl -ab tutorial.html opens the file tutorial.html in the current window but keeps terminal in focus. This is handy if you need to traverse a few directories and cherry pick a number of files to be opened.

Arguments:
–project : Load the given project
–command : Run the given command
-n or –new-window: Open a new window
-a or –add: Add folders to the current window
-w or –wait: Wait for the files to be closed before returning
-b or –background: Don’t activate the application
-s or –stay: Keep the application activated after closing the file
-h or –help: Show help (this message) and exit
-v or –version: Show version and exit

 

2. Open files in current sublime text window

This was one of the biggest annoyances for me when switching over from coda. Whenever I would drag a file into the sublime dock icon it would open a brand new instance of sublime when I just wanted to view it along with the rest of my files. Turns out this is a super simple fix.

HitCommand + Shift + P to bring up the sublime launcher type “user global settings and hit enter. This file is similar to a .vimrc file and holds all of your custom settings. This file wont be written over when you upgrade like default global settings. Once you have this file open, add the following line:

"open_files_in_new_window": false

 

3. Get Code Hinting in Sublime Text 2

Sublime Text 2 Code HintingOne feature that Coda has just slam dunked is their code hinting. I rarely ever have to type entire key words. A solution for getting code completion working in Sublime Text is to install SublimeCodeIntel, a port of the Komodo editor code  completion engine. It isn’t perfect, particularly in CSS file, but its pretty good and gets the job done.  Download the repo here and drop it into your packages folder at ~/Library/Applications/Sublime Text 2/Packages

 

 

4. Upload with Transmit shortcut

If you are working on a code n’ upload project you need to be able to edit a file and quickly FTP it up to your server. Since sublime doesn’t have this built in like Coda does, you’ll need to use the Transmit FTP client.

First, set up your project folders in transmit.

Next, install Sublime Transmit Docksend, The way this package works is by simulating a docksend (drag and drop a linked local file) to transmit when a key combination is pressed.

Finally, when editing a local file that is linked up in transmit, hitCommand + Shift + U and the file will upload. If you are editing /js/scripts.js locally, the file will be uploaded to /js/scripts.js on your server in split second.

5. Create your own snippets!

Its a given that you should have already installed Zen Coding, but there are always snippets that are developer specific that you use on a daily basis. For me, I usej + tab  to expand into a jQuery selector $(' '); To setup your own snippets, go to tools->New Snippet. The XML markup is fairly straightforward so I wont go into it. Just plop your code inbetween and ]]>. You can even set areas to tab through the snippet as well as defaults.

Here a basic snippet using the letter j as the tab trigger. When I tab, the cursor will be place inside the jQuery selector, tab again and I’m outside the selector ready to call a method on it.

<snippet>
    <content><![CDATA[\$('${1}')${2};]]></content>
    <tabTrigger>j</tabTrigger>
</snippet>

Thats is!

There is a lot more to Sublime Text 2 and many cool new features such as code folding and Vim support are currently in development. I will go into many more features in coming blog posts. Want to know how to do something? Just ask in the comments below! Be sure to also Follow me on Twitter.

This entry was posted in Sublime Text and tagged . Bookmark the permalink.

22 Responses to 5 Helpful Tips for moving to Sublime Text 2

  1. Claus says:

    I only recently switched to Sublime, I don’t like Textmate and never quite understood why it’s so popular. However, thanks for this post!

  2. Fladson says:

    Very nice, the command line utility works fine on ubuntu too, now it becomes my main text editor for Rails projetcs.

  3. kc says:

    Great discussion. I would like to implement code completion for the codeigniter php framework. would number 3 or 5 above work for this?

    KC

  4. Edwin Knuth says:

    Thanks so much for the subl link tip. I missed being able to open files from the command line. Another option is to create a symlink in your ~/bin directory so you don’t have to use sudo:

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

  5. The Docksend shortcut is Command + U (at least in my installation together with Swedish keyboard, Mac) . Thanks for great tips.

  6. Eli says:

    Came from Google for your second point. There are some slight differences in the version I’m using (Sublime Text 2) but excellent work, and thanks for posting this!

  7. Matt says:

    Thanks for this post, particularly for the link to the SublimeCodeIntel Transmit Docksend packages. The latter is exactly what I had been after. I was a long time Coda user and I think this basically put the proverbial nail in the coffin…

  8. Pingback: Goodbye Textmate, I’m just testing Sublimetext 2: what I like, what I don’t | BASIC TRADING MULTIMEDIA

  9. Chris says:

    True that FTP isn’t built-in (like Coda – I’m a Coda owner, too) but the solution is as simple as adding the Sublime SFTP package …

    http://wbond.net/sublime_packages/sftp and follow the instructions.

    • wesbos says:

      I’m using this now, its amazing!

      • Chris says:

        I started using ST2 about a week or so ago after trying it a few times before but never giving it a good chance. With SFTP plus a few other packages installed, it’s still as fast as when it has no packages.

        Coda has some serious competition now – I just hope Coda 2 has something special up its sleeve! :)

  10. Rafael says:

    SublimeCodeIntel doesn’t work for me.

  11. Hey thanks for the extra packages mentioned. I just installed Sublime and found your post. Going to go hook up these packages now and see if I can speed up the dev time a little more :)

    Cheers,
    Sean.

  12. Hey thanks for the extra packages mentioned. I just installed Sublime and found your post. Going to go hook up these packages now and see if I can speed up the dev time a little more
    Cheers,
    Sean.

    p.s. Reposted my comment as URL was wrong. Thanks!

  13. Adam J. says:

    Thanks for the post. Some great tips here. Especially helpful tip about opening files in the same/current window.

    I recently wrote a post with some more tips and tricks for ST2:

    http://adamjohnsondesign.com/blog/sublime-text-2-so-good/

    Enjoy and thanks again.

  14. Pingback: Sublime Text 2 | Software for Text...

  15. Pingback: Quora

  16. evgeniy says:

    >Upload with Transmit shortcut
    command+u
    without shift
    ;-)

Leave a Reply

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

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>