Autoclose

From BBEditExtras
Jump to: navigation, search

There are several ways to close brackets, braces, etc. in BBEdit. You can also control how BBEdit uses them to complete different things in different languages.

By far the best way is to use AutoPairs, a freeware preference pane that allows you to autopair in any application, including BBEdit. You can control how it works in each application. You only have to install it once, and it will continue to work. (Note that the instructions are slightly out of date -- you no longer have to paste in the path to AutoPairs, OS X 10.9.5 and later should recognize the AutoPairs pref pane automatically.)

Another more manual way is simply to create a Clipping for the open character, which includes the close character, and then assign that Clipping to a modified version of the open character (or any other modified keystroke). You only have to do this once. For example, if you want to add a closing brace any time you open a brace, type the following into a new BBEdit document:

    {#INSERTION#}

Highlight that text, right-click on it, and choose Save Selection As Clipping. If you only want that Clipping to fire off when you're using, say, CSS, then save it to the CSS.css Clipping file with a random name -- say, "closebrace". If you want it to work in all file types, add it to Universal Items. To assign the keystroke, go to Window->Palettes->Clippings, and choose the Set Shortcut option at the top right. Type a keystroke in there (a common one is control-[, which is simply replacing the shift for the control key). Now, whenever you type the Control key followed by [, you'll get a brace.