Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bind double-[ to keyboard shortcut

5 views
Skip to first unread message

perd...@gmail.com

unread,
Jan 4, 2010, 6:01:43 AM1/4/10
to
In a previous installation of Mathematica, I had (on a Mac) Command-
Alt-8 bound to the character representing double-[ for use in list
indexing.

I lost this setup in an upgrade and now I cannot create this
customization again :-(

Anyone know of what I'm talking?

Thanks in advance!

..Per

ragfield

unread,
Jan 5, 2010, 1:42:53 AM1/5/10
to

In recent versions of Mac OS X (I think back to 10.4) cmd-opt-8 is a
shortcut used by the OS to enable/disable the screen zooming feature.
The OS steals these keystrokes before Mathematica ever sees them. If
you don't use this feature you can remove/disable the shortcut for it
by unchecking the checkbox at System Preferences > Keyboard > Keyboard
Shortcuts > Universal Access > Turn zoom on or off. With this
shortcut disabled you will be able edit your MenuSetup.tr or
KeyEventTranslations.tr to use this key combination.

-Rob

Peter Breitfeld

unread,
Jan 5, 2010, 1:49:17 AM1/5/10
to
"perd...@gmail.com" wrote:

To achieve this I change the file
/Applications/Mathematica.app/SystemFiles/FrontEnd/TextRessources/
Macitosh/KeyEventTranslations.tr

Add the following to this file: (BE CAREFUL, ALWAYS MAKE A COPY OF THIS
FILE BEFORE EDITING IT, IF YOU MADE A MISTAKE, MATHEMATICA WILL NOT WORK
ANY MORE)

Item[KeyEvent["<",Modifiers->{Control}],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`SelectedNotebook[],
"\[LeftDoubleBracket]\[RightDoubleBracket]",After],
FrontEndToken["MovePrevious"]}]]

Now Ctrl+ < will bring up the opening and closing double-brackets with
the Cursor placed in between.

I changed the other parentheses, brackets and braces the some way, e.g.

Item[KeyEvent["("],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`SelectedNotebook[],
"()",After], FrontEndToken["MovePrevious"]}]]

--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de

perd...@gmail.com

unread,
Jan 7, 2010, 2:33:32 AM1/7/10
to
By accident when searching for Mathematica and AppleScript ressources,
I stumbled upon the original blog-post. The solution resembles Peters:

Item[KeyEvent["[", Modifiers -> {Control}],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[LeftDoubleBracket]", After]}]],
Item[KeyEvent["]", Modifiers -> {Control}],
FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[RightDoubleBracket]", After]}]],

For future reference: http://qwan.org/2009/03/26/typing-=E2=9F=A6-and-=E2=
=9F=A7-in-mathematica/#comments

Thanks to you both!

..Per

On Jan 5, 7:49=C2 am, Peter Breitfeld <ph...@t-online.de> wrote:


> "perda...@gmail.com" wrote:
> > In a previous installation of Mathematica, I had (on a Mac) Command-
> > Alt-8 bound to the character representing double-[ for use in list
> > indexing.
>
> > I lost this setup in an upgrade and now I cannot create this
> > customization again :-(
>
> > Anyone know of what I'm talking?
>
> > Thanks in advance!
>
> > ..Per
>
> To achieve this I change the file
> /Applications/Mathematica.app/SystemFiles/FrontEnd/TextRessources/

> =C2 Macitosh/KeyEventTranslations.tr


>
> Add the following to this file: (BE CAREFUL, ALWAYS MAKE A COPY OF THIS
> FILE BEFORE EDITING IT, IF YOU MADE A MISTAKE, MATHEMATICA WILL NOT WORK
> ANY MORE)
>
> Item[KeyEvent["<",Modifiers->{Control}],

> =C2 =C2 =C2 FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`Sel=
ectedNotebook[],
> =C2 =C2 =C2 =C2 "\[LeftDoubleBracket]\[RightDoubleBracket]",A=
fter],
> =C2 =C2 =C2 =C2 =C2 =C2 =C2 FrontEndToken["MovePrevi=
ous"]}]]
>
> Now Ctrl+ < =C2 will bring up the opening and closing double-brackets w=


ith
> the Cursor placed in between.
>
> I changed the other parentheses, brackets and braces the some way, e.g.
>
> Item[KeyEvent["("],

> =C2 =C2 =C2 FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`Sel=
ectedNotebook[],
> =C2 =C2 =C2 =C2 "()",After], FrontEndToken["MovePrevious"]}]]

0 new messages