[OS X TeX] smart-Typing-Pairs with texshop
Herbert Schulz
herbs at wideopenwest.com
Sun Dec 6 07:58:57 EST 2009
On Dec 6, 2009, at 4:49 AM, Diego Gruber wrote:
> Hi Alan,
>
> I'm fairly new to TeXShop and this list and was wondering the same thing a
> few days ago. I found out there are several ways to do this. Not sure this
> is the "proper" way but it works for me: you should modify the
> autocompletion file (you find it in the Library->TeXShop->Keyboard folder...
> do this in a program like TextWrangler and not within TeXShop, which for
> some reason gave me lots of problems). Once you open the file and see what's
> in there it's fairly obvious how it works. You can modify it so that when
> you strike a certain <key> it automatically inserts the specified <string>,
> including the selected text #SEL# and the cursor #INS# in the specified
> positions. For example you could open a parenthesis and have TeXShop
> automatically close it and put the cursor inside, perhaps enclosing selected
> text within these parentheses. Then you would write
>
> <key>(</key>
> <string>(#SEL##INS#)</string>
>
> For your second request I also found it very easy to define a new macro.
> Open the macro editor and create a new item that for instance performs the
> action (#SEL#) and assign it a keyboard shortcut. This will replace selected
> text by (selected text), as requested.
>
> Hope that helps,
>
> Diego
>
>
> On Sun, Dec 6, 2009 at 10:43, Alain Matthes <alain.matthes at mac.com> wrote:
>
>> Hi
>>
>> I found any answer to this question on the net : how to get pair of
>> brackets and parentheses
>> automatically. I would like to get (..) [...] with only one action and
>> like in TextMate
>> I would like replace a "selected text" by "(selected text)" or "[selected
>> text]".
>>
>> Is it possible with TexShop ?
>>
>> Best regards.
>>
>> Alain Matthes
>>
Howdy,
Beat me to it... :-)
The difference between the two methods is that using method one, modification of the ~/Library/TeXShop/Keyboard/autocompletion.plist file, actually binds the sequence to the keystroke so you (almost---see the rest of this description) always get the expansion. This can be very handy for things like {->{}, _->_{}, ^->^{} (with the selection and insertion point between the braces) because when you want the alternative meaning (e.g., a `printed' {) you need to escape it (e.g., \{) and TeXShop is smart enough NOT to complete the pair if the { is escaped. I'm not sure if this is desirable for items you don't usually escape.
The second method allows you complete control over when the expansion occurs by assigning a keyboard shortcut to the macro. The keyboard shortcut must contain the Command key and shouldn't conflict with other shortcuts in the menu system. I tend to use combinations like Ctl-Cmd-... but there may be conflicts anyway; the worst thing that happens is that the binding doesn't work and you have to change it. I tend to use this expansion for things like \emph{} (with the selection and insertion point between the braces) and bound that to Cmd-I (available in the latest versions of TeXShop since it has been removed from another binding).
Which method you use is up to you.
Good Luck,
Herb Schulz
(herbs at wideopenwest dot com)
More information about the MacOSX-TeX
mailing list