Though it pained me at the time, last year I felt compelled to leave my favorite text editor– BBEdit– for TextMate. I had been using BBEdit for years and years as my IDE, but when I made the move to Ruby on Rails I followed the lead of other Mac-based Rails developers and adopted TextMate. Although the move was relatively painless, something just didn’t feel right.
I won’t do a feature-by-feature comparison, but I will say that while the Rails-specific features were nice, there were a lot of BBEdit niceties that I missed, or whose TextMate analogues I found lacking.
So when Bare Bones released BBEdit 9 a couple of months ago, I decided to test the waters and see if I could return to my old favorite without losing the productivity gains I got with TextMate. I’m happy to say that I haven’t opened TextMate at all since then. I initially stumbled across (and reported) a few bugs related to the handling of Ruby in the editor, but was amazed at the incredibly fast response and turnaround time for fixes.
Project Management
Besides the extended Ruby on Rails language support, probably the most important BBEdit feature from a Rails development perspective is the new Project functionality. Long-time BBEdit users will probably recognize this as an evolution of the Disk Browser feature.
Projects are basically a group of related files and folders from the file system. So in a typical Rails app, the BBEdit Project file would contain all of the files and folders in your application’s root directory.
Projects provide single-window editing capability, which is vital while working across model, view, helper, and controller files. You can slide open the Documents Drawer to see all of the docs you’ve got open, and move between them using a keyboard shortcut; I think that command-] and command-[ are the defaults.
BBEdit’s Project window…
…compared to TextMate’s interface.
This pretty much parallels TextMate functionality, with the exception that Project files and folders are not limited to a single root folder. You can also create Collections within projects, so if you have conf files related to your project (e.g. host files, vhosts, or what have you) you can maintain quick access to them from the Project window.
To create a Project in BBEdit, simply go to New -> Project, and then drag-and-drop your files and folders. You can save the Project file wherever you like– I keep all of the BBEdit Project files in my ~/Documents/projects/ folder, at the same level in the file hierarchy as my Git repositories. This keeps them easy to access but out of source control.
Scoping Multi-File Search
BBEdit has always provided fast and robust search capabilities, especially compared to the dog-slow multi-file searching in TextMate.You also now have ability to edit right from within the search results list. Nice. But take a few minutes to optimize the way you search, and you’ll be even more productive.
In the multi-file search dialog, set up a File Filter defining Rails source code as any file with one of the following line endings:
- .rb
- .erb
- .rjs
- .html
- .rthml
- .yaml
- .css
- .js
- .haml
Then click ‘Other’ in the find dialog box and select just the folders you’re going to want to search in (most likely app/models, app/views, app/controllers, and app/helpers). Otherwise, you may find yourself with a lot of false positives as BBEdit searches through log/, lib/, and vendor/. Be sure to save your search set and name it for your project.
Clippings
Clippings make short work of Rails coding in BBEdit. Clippings are just snippets of code that can be inserted with a few key presses, and BBEdit 9 comes with two sets just for Rails development: Ruby, and Ruby in HTML. Create a keyboard shortcut for the Clippings > Insert Clipping menu item by bringing up Preferences > Menus > Clippings and selecting Insert Clipping. (I use option-command-c.)
To insert a clipping, simply invoke the clipping pallete using your shortcut, and start typing the clipping tag that you want; for example, to insert a template for a class definition, start typing “cla”, and when auto-complete shows the correct clipping, just hit enter.
Now you can tab through the placeholders (in this case, the ClassName and the interior of the class) and enter the appropriate code.
You can also create your own snippets; check the BBEdit help for instructions.
I’ve created a quick reference sheet that organizes all of the Rails-related clippings on one page, suitable for hanging on the wall near your desk:
No Comments »