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

Herbert Schulz herbs at wideopenwest.com
Sat Jun 1 11:58:39 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

Howdy,

I'm sorry for coming back to this so late but it has been such a long time since I looked at keybindings that I didn't realize that the #SEL# (the selection) CAN be part of the key binding. E.g., I have _ bound to _{#SEL##INS#} so pressing _ will surround any existing selection with _{ and } while leaving the insertion point between the braces. If you want the insertion point to end up outside the braces bind _ to _{#SEL#}#INS# (even _{#SEL#} might work though I haven't tried it.

Sorry to come back to this so late.

By the way the keybindings code is smart enough that if you type \_, to get an underscore in typeset text, it will NOT expand the _. If you want to type _ by itself, e.g., in verbatim text or a url, you will still need the macro.

Good Luck,

Herb Schulz
(herbs at wideopenwest dot com)






More information about the MacOSX-TeX mailing list