[OS X TeX] key bindings in ``math mode'' only

Herbert Schulz herbs at wideopenwest.com
Tue May 28 06:14:21 EDT 2013

On May 25, 2013, at 2:04 PM, Nicolae Garleanu <garleanu at haas.berkeley.edu> wrote:

> There is perhaps another possibility. Can one set it up so that,
> (i) if one types, say, xt+1, then highlights (shift back arrow) t+1 and
> types _, one ends with x_{t+1} and the cursor after the closing bracket;
> (ii)  if one types just _ (nothing highlighted), then only _ is written?
> In other words, change the key binding so that it works only for
> *non-empty* selections? (And move the cursor to the end thereafter, but I
> think that that's just a matter of moving #INS#?)
> Nicolae


You can do that with a Macro but not a Key Binding. The #INS in a key binding really represents where the insertion point is to be located, not where a selection is to be put. As a matter of fact the key binding acts just like a regular pressed key, what gets inserted replaces the selection. In a macro you have #SEL as well as #INS.

As things stand Key bindings and Macros blindly insert what they are bound to and can't examine whether a selection is empty or not so your other request won't work either.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)

More information about the MacOSX-TeX mailing list