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

adding a keyboard shortcut for double brackets

2,080 views
Skip to first unread message

Barrie Stokes

unread,
Jan 19, 2011, 5:30:03 AM1/19/11
to
Hi All

I note in the Help page "Keyboard Shortcut Listing" that for example entering Alt+] gives the pair of single brackets [] with the cursor between them.
No such shortcut is listed for the double brackets [[ ....]]. Can this be added to one's installation of Mathematica? I seem to be doing "Esc [ [ Esc Esc ] ] Esc left arrow" quite a lot in a Windows 7 system.

Barrie


DrMajorBob

unread,
Jan 20, 2011, 6:30:37 AM1/20/11
to
Just push the one for brackets TWICE, and voil=E1!

Double brackets... without learning a new shortcut.

Bobby


--
DrMaj...@yahoo.com

Barrie Stokes

unread,
Jan 20, 2011, 6:30:48 AM1/20/11
to
Hi Bobby

On your Windows machine, does Alt+] and then Alt+] again give the same
result as my 9 keystroke sequence "Esc [ [ Esc Esc ] ] Esc left_arrow",
i.e. the pair of characters represented at the Expression level by
\[LeftDoubleBracket] and \[RightDoubleBracket], with cursor in the
middle (achieved by my left-arrow)?

If it does, then sacre bleu! It doesn't on my PC; first thing I tried.
Otherwise, ...

I want the nice notation without 9 keystrokes each time.

Barrie

>>> On 20/01/2011 at 10:37 am, in message
<op.vpkw8...@bobbys-imac.local>,

Barrie Stokes

unread,
Jan 20, 2011, 6:30:59 AM1/20/11
to
Hi David

Re:"Why not simply do the shortcut twice to obtain [[]]",
because I want the notation to be same as the result of my "Esc [ [ Esc Esc ] ] Esc left arrow" keystroke sequence, i.e. I want not the repeated single "[" and "]", but the pair of symbols represented at the Expression level by \[LeftDoubleBracket] and \[RightDoubleBracket].

The only key on a PC that could be thought of as equivalent to the Macintosh Command key is the "Windows" key, and it doesn't seem to play the same role. On my Windows 7 system, Alt+] is sufficient to get the pair of single brackets [] with the cursor between them.

Barrie


>>> On 20/01/2011 at 4:41 am, in message
<OFFAEBBE61.CF534136-ON852578...@terc.edu>, David
Carraher <david_c...@terc.edu> wrote:
> Barrie,
>
> BTW, the shortcut on a Mac seems to be Alt+Command+]
>
> Why not simply do the shortcut twice to obtain [[]] ?
> It works for me.
>
> David

DrMajorBob

unread,
Jan 20, 2011, 6:31:11 AM1/20/11
to
Well, no. I don't get the "pretty" brackets... but I don't care about that.

(And I never touch a Windows machine, for fear of getting some terrible
infection, like gangrene.)

Bobby

On Wed, 19 Jan 2011 17:51:08 -0600, Barrie Stokes
<Barrie...@newcastle.edu.au> wrote:

> Hi Bobby
>
> On your Windows machine, does Alt+] and then Alt+] again give the same
> result as my 9 keystroke sequence "Esc [ [ Esc Esc ] ] Esc left_arrow",
> i.e. the pair of characters represented at the Expression level by
> \[LeftDoubleBracket] and \[RightDoubleBracket], with cursor in the
> middle (achieved by my left-arrow)?
>
> If it does, then sacre bleu! It doesn't on my PC; first thing I tried.
> Otherwise, ...
>
> I want the nice notation without 9 keystrokes each time.
>
> Barrie
>
>>>> On 20/01/2011 at 10:37 am, in message
> <op.vpkw8...@bobbys-imac.local>,
> DrMajorBob <btr...@austin.rr.com> wrote:
>> Just push the one for brackets TWICE, and voil=E1!
>>
>> Double brackets... without learning a new shortcut.
>>
>> Bobby
>>
>> On Wed, 19 Jan 2011 04:30:17 -0600, Barrie Stokes
>> <Barrie...@newcastle.edu.au> wrote:
>>

>>> Hi All
>>>
>>> I note in the Help page "Keyboard Shortcut Listing" that for example
>
>>> entering Alt+] gives the pair of single brackets [] with the cursor
>
>>> between them.
>>> No such shortcut is listed for the double brackets [[ ....]]. Can
> this
>>> be added to one's installation of Mathematica? I seem to be doing
> "Esc [
>>> [ Esc Esc ] ] Esc left arrow" quite a lot in a Windows 7 system.
>>>
>>> Barrie
>>>
>>>
>>


--
DrMaj...@yahoo.com

gl...@flashmail.com

unread,
Jan 22, 2011, 3:20:45 AM1/22/11
to
Hello Barrie,

What you want is not difficult. Since you will modify a system file,
make a back-up copy.

Open the
file:
($InstallationDirectory)\SystemFiles\FrontEnd\TextResources\Windows\KeyEventTranslations.tr

Modify it to read:
.
.
.
EventTranslations[{

(* User-added keyboard commands *)
Item[KeyEvent["[", Modifiers -> {Control}],
FrontEndExecute[{
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[LeftDoubleBracket]", After]
}]],
Item[KeyEvent["]", Modifiers -> {Control}],
FrontEndExecute[{
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[RightDoubleBracket]", After]
}]],
Item[KeyEvent["]", Modifiers -> {Control, Command}],
FrontEndExecute[{
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[LeftDoubleBracket]", After],
FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],
"\[RightDoubleBracket]", Before]
}]],

(* Evaluation *)
.
.
.
Where the vertical . . . represents the original lines above and below.

This adds three keyboard combinations, where "[[" and "]]" represent
the proper forms, and "_" the cursor position:

Ctrl+[ -> [[_
Ctrl+] -> ]]_
Ctrl+Alt+] -> [[_]]

If you do not use the first two, simply remove those blocks from the
file. It should be easy enough to change the keys or add other
commands once you have a look at the file.

Have a good day,

Paul

fizzy

unread,
Jan 23, 2011, 5:32:39 PM1/23/11
to
This question prompted me to look at Classrom Assistant...i'd been curious for a while what I could get from this palette...I sent a reply the other day about it but it turned out to be incomplete...

actually CA has a double left/right bracket icon....under Typsetting and the very first folder you can find a double bracket button there...

jerry blimbaum


----- Original Message -----
From: Barrie Stokes
To: math...@smc.vnet.net
Sent: Wednesday, January 19, 2011 4:30 AM
Subject: adding a keyboard shortcut for double brackets


Hi All

I note in the Help page "Keyboard Shortcut Listing" that for example entering Alt+] gives the pair of single brackets [] with the cursor between them.

No such shortcut is listed for the double brackets [[ ....]]. Can this beadded to one's installation of Mathematica? I seem to be doing "Esc [ [ Esc Esc ] ] Esc left arrow" quite a lot in a Windows 7 system.

Barrie


David Bailey

unread,
Jan 25, 2011, 4:21:40 AM1/25/11
to
An interesting alternative, is to create a new menu item, by editing
MUNUSETUP.TR (after backing it up!). Menu items can be set up with
nmemonic (such as the standard Alt-FO to open a file). A menu needs
slightly more keyboard characters, but you can always find the added
menu items by exploring the Mathematica menu. You can add your own Item
structure, such as:

Item["&Something",FrontEndExecute[someCommand[]], MenuEvaluator->Automatic]

The someCommand can contain any Mathematica operations, such as
NotebookWrite[InputNotebook[],"[[]]"
];SelectionMove[InputNotebook[],Before,Character,2]

David Bailey
http://www.dbaileyconsultancy.co.uk

Sjoerd C. de Vries

unread,
Jan 25, 2011, 4:19:17 AM1/25/11
to
Hi Paul,

It looks good, but doesn't work for me. Nothing happens. Are you sure
BTW that the last keyname should be "Command" instead of Alt? Sounds
mac-speek to me.

Cheers -- Sjoerd

On Jan 22, 9:20 am, gl...@flashmail.com wrote:
> Hello Barrie,
>
> What you want is not difficult. Since you will modify a system file,
> make a back-up copy.
>
> Open the
> file:

> ($InstallationDirectory)\SystemFiles\FrontEnd\TextResources\Windows\KeyEv=


entTranslations.tr
>
> Modify it to read:
> .
> .
> .
> EventTranslations[{
>
> (* User-added keyboard commands *)
> Item[KeyEvent["[", Modifiers -> {Control}],
> FrontEndExecute[{

> FrontEnd`NotebookWrite=
[FrontEnd`InputNotebook[],
> "\[Lef=


tDoubleBracket]", After]
> }]],
> Item[KeyEvent["]", Modifiers -> {Control}],
> FrontEndExecute[{

> FrontEnd`NotebookWrite=
[FrontEnd`InputNotebook[],
> "\[Rig=


htDoubleBracket]", After]
> }]],
> Item[KeyEvent["]", Modifiers -> {Control, Command}],
> FrontEndExecute[{

> FrontEnd`NotebookWrite=
[FrontEnd`InputNotebook[],
> "\[Lef=
tDoubleBracket]", After],
> FrontEnd`NotebookWrite=
[FrontEnd`InputNotebook[],
> "\[Rig=

0 new messages