3
$\begingroup$

In version 8 I was a frequent user of the "Use shortcut keys to easily type〚 and 〛" trick.

In version 9, when I try to make the necessary change to KeyEventTranslations.tr, the \[LeftDoubleBracket] and \[RightDoubleBracket] get immediately changed to doubled single-brackets ([[ and ]]). And indeed the shortcuts work, but they insert the doubled single-brackets instead of the single double-brackets. How can the brackets' doubleness be preserved in KeyEventTranslations.tr?

$\endgroup$
3
  • $\begingroup$ This shortcut is the subject of this answer. $\endgroup$ Jan 30, 2013 at 16:21
  • 1
    $\begingroup$ You should enter it via a text editor like vim/emacs (or any other). If you edit it via the front end, it will convert it to [[ $\endgroup$
    – rm -rf
    Jan 30, 2013 at 16:57
  • 2
    $\begingroup$ Yes, it works in v9 without problems. Just use a plain text editor to edit KeyEventTranslations.tr. Do not use Mathematica to edit that file because it may break it. If you did edit it with Mathematica, try to get the original file from the installer and restore it. $\endgroup$
    – Szabolcs
    Jan 30, 2013 at 17:29

1 Answer 1

7
$\begingroup$

I do believe that it should still work under V9, however I personally have added my shortcuts to MenuSetup.tr rather than KeyEventTranslations.tr and they read:

Menu["&Typesetting",
{
...  
    Delimiter,
(*My typesetting shortcuts*)
    MenuItem["Matching ()", FrontEndExecute[{FrontEnd`NotebookApply[FrontEnd`InputNotebook[], "(\[SelectionPlaceholder])"]}],
         MenuKey["8", Modifiers->{"Control","Shift"}]],
    MenuItem["Matching []",FrontEndExecute[{FrontEnd`NotebookApply[FrontEnd`InputNotebook[], "[\[SelectionPlaceholder]]"]}], 
        MenuKey["9", Modifiers->{"Control","Shift"}]],
    MenuItem["Matching {}", FrontEndExecute[{FrontEnd`NotebookApply[FrontEnd`InputNotebook[], "{\[SelectionPlaceholder]}"]}],
        MenuKey["8", Modifiers->{"Control","Command","Shift"}]],
    MenuItem["Matching [[ ]]",FrontEndExecute[{FrontEnd`NotebookApply[FrontEnd`InputNotebook[],"\[LeftDoubleBracket]\[SelectionPlaceholder]\[RightDoubleBracket]"]}], 
        MenuKey["9", Modifiers->{"Control","Command","Shift"}]],
    MenuItem["My costum format function", KernelExecute[ToExpression[myCostumTypessingFunction[]]], 
        MenuKey[".", Modifiers -> {"Control", "Command"}], MenuEvaluator -> Automatic],

This way they are also listed under the menu Insert>TypeSetting> name, along with a helpful reminder of what the shortcut key combination is. The reason for the \[SelectinPlaceholder] is so that you can select some code and use the shortcut to wrap it in parenthesis.

$\endgroup$
1
  • 2
    $\begingroup$ The SelectionPlaceHolder tip is great. Thank you. $\endgroup$ Feb 7, 2013 at 0:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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