Friday, February 10, 2012

My new texteditor Sublime2, Essential packages and Pro tips

This week I read Quick Review of Mac OS X Text Editors for Lua...
In there I saw Sublime2 and since I have never heard of it I went to check it out. After reading the feature list and looking at some screenshots I just knew I have to give it a test drive. After download and install I opened up one of my django models.py file. Immediately recognized the syntax and presented me with a very nice syntax highlighting. To my biggest surprise even auto complete worked. After reading up some of the docs and a couple of blog posts I learned that I can do pretty much anything without my hand ever have to leave the keyboard. I am a longtime vim user (although vim was not my choice of texteditor in day to day programming), and it felt good being able to open files, jump to any function/method and even install new packages without using the mouse. At this point I closed my eclipse and I knew it was not a temporary move. I had tried many texteditors/ides over the years but I always ended up going back to eclipse. Eclipse is a very convenient ide with all the language support I needed, but it is also a resource hug and many times it overkill what I am using it for. Sublime2 is a great compromise with it's functionality and simplicity.

Essential packages
Below packages in my opinion needs to be installed after a fresh new sublime install.
  • Sublime Package Control
  • Soda Theme
  • Bracket Highlighter
  • Prefixr Plugin
  • Djanerio
  • Sublime Linter
  • Sublime CodeIntel
I started with the Sublime Package Control package because once that's installed you can use it to install the rest.:)
  1. Open up Sublime and press Ctrl+` that will open up the console
  2. Paste this 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; 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'
  3. Press enter. It will install the Package Control for Sublime.
  4. Now restart Sublime and you are ready
Now lets install those packages. All you need to do is Press Cmd+Shift+P. This will open the Command Window, type package to sort to the Package commands. Select Install Package and it will bring up the package search window, there just start typing the name of the package and press enter to install. That's all, it just does not get any easier than that.

Update:
To enable the Soda Theme open preferences and user settings. Add this into it

"soda_classic_tabs": true

Pro tips
Here are some of the commands I learned and learned to love spending less than a day with Sublime2. I will keep this list update as I learn more of them.

  • Cmd+Shift+P => Brings up the Command window, you can access pretty much everything here.
  • Cmd+P => Open anything window. My FAVORITE feature, you can just start typing and it will display all the files that insudes the typed in text, then press enter and open it. Seriously this saves a ton of time when you know what file you want to open and it is burried many level deep in directories.
  • Cmd+R => Find any function/method/class window. This is an other huge time saver. Once you typed in text it will display all possible choices, Use the arrow key to scroll through it and it also moves the cursor immediately at the location. Got to love it!
  • Type lorem then press Tab => Inserts a full paragraph of lorem ispum text. I am pretty sure everyone uses it to fill up empty space to represent content.
As you can see I jumped into this love affair head first. So far very impressed with Sublime2 and at this ppint I see no reason why I would need to go back to eclipse, unless I have to write some code for Android which I am not planning on but who knows...
I am going to write up an other post on basic configuration and how to create Projects with Sublime2 and switch between them using your keyboard only.