My impression is that this is something of a religious issue in these
parts. :) I'm with you--while I think programmers should have the option
of being able to turn this off, it's remarkable how much time this
little trick, and its corresponding trick of automatic de-indenting when
you start a line with a close bracket, ends up saving in practice.
The best I've done in BBEdit is create a combination AppleScript and
"Universal Item" clipping to let me do an indent with Ctrl-Return, which
not only isn't really syntax aware, it turned out to be less trivial
than I was originally expecting. The clipping file I called "Return &
Indent" and simply contains this, where "<r>" indicates a return character:
<r>
#INDENT##script maketab.scpt##INSERTION#<r>
(i.e., you need to have a blank line above the code.) The AppleScript is
named "maketab" and contains this:
tell application "BBEdit"
tell text window 1
if expand tabs is true then
set insertText to ""
repeat tab width times
set insertText to insertText & " "
end repeat
else
set insertText to tab
end if
insertText
end tell
end tell
Both of those need to be saved in the "~/Library/Application
Support/BBEdit/Clippings/Universal Items" folder. This is still not 100%
ideal, as BBEdit's autocompletion will try to execute this via any time
I type the word "return" in plain text; I'm not sure if there's a way to
turn that off short of just renaming it something sufficiently weird
that it's not likely to come up (or just turning off autocomplete).
At least for me, the hardest thing to adapt to in BBEdit is that
AppleScript is pretty much essential if you want to learn how to do
extensions. I know some people are very comfortable with AppleScript,
but I am not one of them.
--
Watts Martin <lay...@gmail.com>
At any rate, in BBEdit I have a somewhat more advanced package I put
together that's a collection of Applescripts which includes a "smart
return" function that's not only a syntax-aware indent but does some of
the auto-pairing that TextMate refugees miss. I'll try to get it cleaned
up and online if people are interested. (I confess that against my own
advice of last year I've lately been trying out a competing editor; I'm
waiting for "Take Control of BBEdit" to come out and bring me back to
the fold.)