Ranea.org

Watts Martin’s web space

Editor Actions for BBEdit

Download

Inspired loosely by Ian Beck’s Text Editor Actions for Coda and Espresso, this is a set of actions I found myself missing in BBEdit from other editors that shall remain nameless. (Okay, TextMate and Sublime Text 2.)

In most cases these are other scripts—or modifications of them—that I’ve found on the web, not original work. Sometimes I’ve made changes because the scripts didn’t seem to work in BBEdit 10, or just didn’t work the way I thought they should. My original sources are:

Most of these are fairly self-explanatory. The “Smart Home Move” and “Smart Home Select” scripts override the Command-Left Arrow function to move to the first non-blank character on a line on the first press and to character position zero on the second. You may like that or you may not; after waffling on it, I found that I did.

The “Smart New Line” function is—again, if you’re the sort of coder who likes this sort of thing—pretty cool, in that it examines both the current language and the current line to determine not only how to indent the next line but whether to add things below the line. It can continue bullet lists in Markdown and YAML, add closing parentheses and braces in code blocks, and continue comment blocks in most languages (including “docblock” comments).

There’s also a “Set Tab Width” command which simply sets the tab width on the current buffer, which I sincerely hope Bare Bones will eventually render redundant by adding this to the per-buffer text options dropdown.

Suggested Keyboard Shortcuts

ActionKey
Duplicate Lines^⇧D
Join Line With Next^⇧J
Open Line Up^⇧⏎
Set Tab Width⇧⌘T
Smart Home Move⌘←
Smart Home Select⇧⌘←
Smart New Line^⏎

This overrides the natural command-left function, but I don’t find that a problem in practice. I’m hesitant to override the natural Return function, though!