TextMate to BBEdit switcher’s guide: BBEdit has command-t now! (well, sorta)

For the full details, see here:  https://groups.google.com/d/topic/bbedit/J5YUlmHsVvM/discussion

Now, this feature is wonderful if you’re a long-time BBEdit user. It’s pretty extra awesome if like me you can only run PeepOpen on some of your Macs. And, for switchers looking for a native way to replicate their beloved cmd-t, it’s not bad.

That said I can totally understand why switchers would say “Not the same, not what I want/need”. My dream was to see them re-use the same dialog as the “Insert Clipping” window, which is just like (or damn near, in any event) TextMate’s window. PeepOpen includes extra functionality like showing SCM status.

Still, you can bind it to cmd-t and it’ll work close enough that your muscle memory might not get too confused. And be sure to check out the even more recent betas; they’ve been doing some big performance improvements (one of the reasons I have always kept BBEdit in my Applications folder, even when I’m trying out another editor or using an IDE for stuff like Java).

Some BBEdit goings on

Some cool stuff in BBEdit-land:

  • BLATANT SELF-PROMOTION: my own BBPackage (AFAIK the only on on the internets!) for better Zend Framework hacking. Now includes completion data and other stuff.
  • Clippings clippings! No longer must you look at page 259 of the manual! Also on Github.

I’ve got a few applescripts in progress, like one to emulate the Surround.vim plugin. I have a few big projects to wrap up at work, hopefully I can find the time to finish them.

TextMate to BBEdit switcher’s guide: Bundles and scripts

The power of TextMate, and the reason many people continue to use it today, are the bundles.

BBEdit 10 supports ‘packages’, although this feature is very new and as far as I know, virtually no one is using it.

That said the feature itself is simply a replication of TM’s bundles concept, but the actual features themselves are available already.

Main Points:

Clippings in BBEdit are Snippets in TM.

Syntaxes are handled by Codeless Language Modules. The biggest different here is that BBEdit syntaxes are not “language aware”. The main point of CLMs are to do syntax highlighting and delimit folds, along with setting the clipping set. There are no “tab triggers” related to the syntax of the current language. You can do a LOT with Clippings to emulate this feature, though, but it’s not as pretty as tab triggers (IMHO).

Commands are a combination of Text Filters and Scripts. The manual covers these in great detail, but the short story is filters accept the selection or document on STDIN, and whatever the script returns replaces the selection or document on STDOUT; scripts simply run a command and the output goes to the special script output window.

There is another big takeaway here, which is BBEdit is incredibly scriptable in AppleScript. The only way to interact with BBEdit-the-application is AppleScript. So, things like “select the word at the insertion point” are only possible via AppleScript, whereas in TextMate you may have alternate methods via bundle scripting. (At least, as I recall, anyway, I haven’t done serious bundle devel on TM in some time)

You can have Clippings call AppleScripts which themselves call shell scripts; and you can use AppleScript to drive just about anything on your Mac. AppleScripts obtuseness and awkward syntax (for many programmers anyway) makes it somewhat unpleasant to work with, but there’s an immense amount of power.

Lastly, be sure to check out the sections on the manual about using AppleScript to override menu items. I mentioned this earlier and it’s another somewhat hidden gem in BBEdit.


TextMate to BBEdit switcher’s guide: Command T

What about “Command T”?

In TextMate, cmd-t opens a ‘find file’ dialog, letting users type a few characters of the name of a file in the project and it’ll “drill down”. This is extremely nice for opening files quickly without using the mouse.

Option 1: PeepOpen (most users)

If you have a reasonably modern Mac, you’ll want PeepOpen: https://peepcode.com/products/peepopen. Go buy it right now.

Option 2: The poor sad unfortunates with 32-bit Macs

If like me you use a 32-bit (original) Intel Mac (non-Core 2 Duo), you’re hosed: PeepOpen relies on MacRuby which relies on 64-bit. You might be able to get a version of MacRuby compiled to work under 32-bit (opinions differ as to whether or not it’ll work), but the short answer is “lovers of adventure only”.

So, you can use cmd-d to open files by name; be sure to check “Find all Matches” and, optionally, “Match Wildcards”. This isn’t exact TM cmd-t behavior, but it’s close when you can’t use PeepOpen.


Simple BBEdit Menu Scripts

BBEdit allows users to override menu actions with a small bit of AppleScript.

Here’s something really dopey I whipped up to favor Transmit over the built-in FTP/SFTP:

on menuselect()
tell application "Transmit"
end tell
set troof to true
return troof
end menuselect

(Returning true means, override the menu item entirely; returning false fires the menus action after the applescript as run. I don’t think it’s possible to do ‘return true’ in AppleScript.)

Pretty neat. This is an unexplored region of BBEdit with a lot of potential.