Monday, March 26, 2007

TextMate vs BBEdit: Fight

I'm one of those BBEdit to TextMate converts. I LOVED BBEdit. I wanted to give BBEdit my first born child. LOVED IT. So when I say that I do most of my work in TextMate now, I want you to understand exactly what that means.

I tried out TextMate shortly before BBEdit 8.5 came out. The thing I like about TextMate is that it helps me code. "Hey, buddy, do you want another double-quote (or paren or curly/angle brace) around that?". To me, TextMate always there to do the tedious part of programming. I've also learned the convenience of the todo list - put todo list notes right in your source, and let TextMate find them for you (and present them in a pretty window) for you later.

BBEdit got out of my way and let me work. Textmate does too, but also offered to help (in what I find is a very non assuming way). TextMate is like a ninja, swooping in, making strategic cuts here and there, then swooping back out of the way.)

Example: for loops in C: I can never remember how that middle condition goes. So a long while ago I made a Glossary entry for BBEdit that I would bring up. Solved that problem ('cept I had to have the Glossary window open, or map it to a key I might forget). In TextMate I just type "for", hit tab, and (assuming I'm editing a C file) my for loop pops up. One more tab press takes me to (in this case) the type of the counter variable. Another tab: name of the counter. Another tab: initial value of the counter. Another tab: the condition part. So on and so forth.

I had tons of BBEdit filters that I created over time. Filters to manage CVS conflicts, filters to translate characters to HTML entities, filters to count characters in the selection. All done for me already in TextMate. (To be fair, maybe half of the filters I used in BBEdit I have to reimplement in TextMate. Foowey.)

I like how the community contributes to TextMate. There are tons of Bundles for TextMate, all centrally accessible. BBEdit doesn't have anything to that extent. The TM community has people that use the (say) the LaTeX bundle every day, and they send improvements to the bundle in, community style. Same with all the other bundles.

Praise for TextMate aside, BBEdit 8.5 is really good, and I miss some features from it. Being able to fold arbitrary ranges is a great idea. TextMate's Find functionality sucks (why can't I search through arbitrary folders? I've been using grep on the command line for this now that I'm in TextMate!). The TextMate answer is that you can make projects by dragging a folder onto TextMate. But have they ever tried making a project with lots of items in it? SLOOWWWW. Ever tried searching the same? SLOWWW... or at least, apparently. No progress bar, no "Working", no nothing). I miss BBEdit's Find In Folder/Find In Search Results.

I also do miss how BBEdit had dialogs for some HTML tags. "Hey, pick a file, set this set that, all in this dialog". Hey, that's cool. (Recent additions to TextMate make this more possible than it has been in the past, so its just a matter of time now).

I miss BBEdit's function popup, because TextMate's seems to not work so well (usually the reason is that TextMate's grammar parser can't handle a function declaration spanning multiple lines). Sometimes these things are easy changes: I complained that Pascal prototypes showed up in the Symbols list, and soon enough I had my fix in, made by a member of the TextMate community (thanks Chris!). Yet, when I'm in BBEdit I miss TextMate's Go To Symbol (Function) dialog box where I can go to a function just by typing.

I don't mind TextMate's piss poor AppleScript support. Lately I've been using Python and appscript instead of AppleScript anyway. (Yes, there are a number of Bundles that use osascript as a crutch to trigger Applescripts).

The good thing is that for comands you can specify the language to use with a shebang line, just like shell scripts (TextMate defaults to bash, even if your login shell is not). There's also that AppleScript shell I thought I saw...

For scripting TextMate has two-ish options (which can be combined): snippets/commands and macros. Snippets/Commands are just shell scripts, but macros are different. Remember recording macros with QuicKeys - watch me do this thing, then replay it when I hit these keys? TextMate has that built right in. These macros are saved to plists, so if you want to implement a macro that Finds all, even though there's no button for Find All in the Find panel, you go into the plist and edit the command/options TextMate sends itself. I've written a few macros, but most of my work is snippet/command based.

Here's the thing though. The other day I was using BBEdit and I remembered why I like(d) it so much. Actually, it was less of a list than a "ahhh, this feels nice and clean" feeling. Or the toolbar at the top showing me what line endings we have (I miss this a LOT in TextMate), setting display options (soft-wrap, etc), and markers. (I'm of two minds on markers. When I'm setting them I say "I'll need this in the future", but then I never use them. So maybe TextMate's method of just "star"ing lines is good. But a list of star-ed lines would be cool too.).

In BBEdit, maybe I like that windows can arbitrarily have drawers (makes it easy to group header and source files together), or that Switch To Header File always brings up the correct file (instead of getting confused by files with ~Number at the end, what I use to mark Rolled Back files: CVS files with changes that I don't want, or don't think I want now). Maybe I want to see the Margin Indicator/Page Guide without necessarily wanting to wrap to it.

I really like how I can customize TextMate exactly how I want. BBEdit's Text Colors preferences work, but TextMate's themes really blow these out of the water. Want C++ public/private/protected declarations to have a different color? Add storage.modifier.c++ to your theme. Really don't like how the Todo bundle works? Modify it yourself - it's just Ruby. (Submit a patch if you want to, or keep your modifications to yourself. TextMate will try to preserve your modifications. I submitted a patch for the Todo bundle a few months ago, and now thanks to me Todo can ignore folders by setting the TM_TODO_IGNORE environmental variable - which can be set at the application level or project level.

My take on the TextMate book: it's a OK Guide style book, but a poor reference book. You'll learn a lot, but it'll take some work for you to connect the dots and figure out how some of TextMate's magic works. I helped review the book before it went to print, and I saw some of my problem areas fixed, but upon reflection there are tons of other things that really need fixing. I don't mind when a book talks about the same thing in two places: one time as an "here's how to use it" and one time as a "here's how it works"... but then please give be a reference to the other area where you talk about it, so I can easily flip back and forth. There's also too much (in my mind) of the former kind of descriptions, and not enough of the later kind. This means it's hard to find details on how you can modify something to fit your purposes.

Then there are other things in the TextMate book that bother me: like in Chapter 3 there are two different lists of Emacs key bindings that TextMate supports (why not just one??!). Things like that.

See also: review of textmate book on Slashdot