Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Is it possible to program the Front End to automatically format double square brackets without having to type Esc[[Esc each time? It's awful to have to type Esc four times for each Part expression, and even more annoying to visually parse the unformatted double brackets.

See also this entry in MathGroup archive: adding a keyboard shortcut for double brackets

share|improve this question
I edited the KeyEventTranslations.tr file to add my own shortcuts. –  Silvia May 6 '12 at 2:00
Thanks Silvia, could you provide details please? –  alancalvitti May 6 '12 at 2:04
Assuming you are under win, open the file in a text editor, add a line like Item[KeyEvent["[", Modifiers -> {Control}],FrontEndExecute[{FrontEnd`NotebookWrite[FrontEnd`InputNotebook[],"[L‌​eftDoubleBracket]", After]}]] –  Silvia May 6 '12 at 2:13
add comment

2 Answers

up vote 26 down vote accepted

Some approaches are discussed in this question on StackOverflow. Original references to these go to Szabolcs's webpage and a MathGroup posting by Mr.Wizard.

To summarize, you copy the file: $InstallationDirectory/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr to $UserBaseDirectory/ (with the same directory tree) and add the following modifications after EventTranslations[{ in the file:

Item[KeyEvent["[", Modifiers -> {Control}],
                "\[LeftDoubleBracket]", After]
Item[KeyEvent["]", Modifiers -> {Control}],
                "\[RightDoubleBracket]", After]
Item[KeyEvent["]", Modifiers -> {Control, Command}],
                "\[LeftDoubleBracket]", After],
                "\[RightDoubleBracket]", Before]

These provide the following shortcuts:

  • using Ctrl+[
  • using Ctrl+]
  • 〚〛 using Ctrl+Cmd+]

Replace Command with Alt for Windows/Linux and modify the paths above accordingly.

You can also try Andrew Moylan's suggestion, in the same post, but I haven't tried it.

share|improve this answer
this is a nice trick, however I couldn't get it to work on a German keyboard. Since the [ and ] keys events are generated by pressing Alt-Gr 8 and Alt-Gr 9 it seems Mathematica does not catch the KeyEvent correctly. Switching over to EN keyboard design works however... Any ideas how to capture Alt-Gr? –  Rainer Oct 27 '13 at 10:54
add comment

Edit the KeyEventTranslations.tr file in a plain text editor by adding the following definitions to the first section of the file:


(* Custom shortcuts *)


(* Evaluation *)

Note that these shortcuts are set up to use the "Control" modifier to insert a template for pairs of single/double brackets.

share|improve this answer
add comment

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.