Is there a way around using [[ and ]] for Part in Mathematica?

后端 未结 2 1918
陌清茗
陌清茗 2020-12-23 19:25

Is there a way to avoid having to do ⋮[[⋮ to obtain those great looking brackets for Part?

2条回答
  •  甜味超标
    2020-12-23 19:36

    I have the following addition in /Applications/Mathematica.app/SystemFiles/FrontEnd/TextResources/Macintosh/KeyEventTranslations.tr which lets me enter double brackets with key combinations. You can do the same by modifying the file (where ever it is on your OS). I first learnt of this from Szabolcs's website here. He has other mathematica related stuff there that might be of help to you.

    The commands added are:

    • with Ctrl+[
    • with Ctrl+]
    • 〚〛 with Ctrl+Alt+]

    Equivalents, as listed in the KeyEventTranslations.tr file are:

    Modifiers can be "Shift", "Control", "Command", "Option"

    For Macintosh: "Command" = Command Key, "Option" = Option Key

    For X11: "Command" = Mod1, "Option" = Mod2

    For Windows: "Command" = Alt, "Option" = Alt

    Insert the following after EventTranslations[{ in the above file.

    (* Custom keyboard shortcuts *)
        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]
            }]], 
    

    You're not the only one who's peeved by it. Here's my attempt to avoid having to stretch to hit Esc by mapping Caps lock to Esc. Mr. Wizard also had a couple of questions related to conversion of [[ to .

提交回复
热议问题