Useful Sublime Text 2 stuff

Sublime Text 2 has packages – basically modules made by users that extend Sublime’s functionality.

Package Control is your friend when it comes to finding & installing such packages. Installation instructions are on the site. Once you install it and restart Sublime go to Preferences > Package Control and select Install Package to search for a package and install it.

A great feature of Sublime is that of viewing the same file in multiple panes. So I can open a file, view it in two panes side by side, and any edits I make in one pane will automatically reflect in the other. This is very useful when you have code all over the place in a large file. Without panes you’ll have to keep moving around, but with panes you can stay where you are in one pane and use the other pane to move to where you want to be.

To create a new view of a file go to File > New View into File. This will open a tab with the same file. Next, go to View > Layout and choose a layout (I prefer Columns:2). This will split the Sublime window into two columns. Then all you have to do is drag the tab with the new view into the newly created column, and you’ll have both views side by side! Nice.

Here are the packages I installed (will be updating this list as I add more):

  • Find Function Definition: Let’s me select a function name in my code and press F8 to find the function definition. I expected the package to search the currently open file(s) and find the function definition, but it does not work that way. You have to define a Project first as only files in current project are searched. I have all my code as various sub-folders of a folder anyway, so I just created a new Project by going to Project > Add Folder to Project and added this folder to the Project. Then I went to Project > Save Project As... and saved the Project so I can easily open it in future. I haven’t explored Projects much, but it seems to be a way of clubbing together multiple folders to create a project and defining common settings just for that project. When you save the Project two files are created, and this is the impression I got from looking at those files.
  • Origami: Makes the aforementioned task of creating new views etc very easy. Creates a menu under View > Origami (and defines keyboard shortcuts) to create new panes, clone the open file into the new pane, etc.

Good stuff!