How can I automatically replace [[ and ]] with the [LeftDoubleBracket] and [RightDoubleBracket] operators? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Automating Esc [[ Esc formatting?On an existing notebook, how to transform all “double brackets” into “DoubleBracket”Convenient string manipulationHow to define a vector with automatically added symbolic elements with subscriptsHow to convert an image to a compressed string representation equivalent to one copied to clipboard by `CopyToClipboard[image]`?Incorporating Built-In Function Options/Parameters into ShorthandDifferentiating a Dot ProductPostfix Double Slash Notation with Multiple ParametersHow to construct custom operators with precedence?Can symbols like + or * be used to denote the Plus and Times functions?How to efficiently input matrices in Mathematica (compared to what MATLAB offers)Define a new Front End Syntax for Function Argument Checking & Debugging

How is simplicity better than precision and clarity in prose?

Finding the path in a graph from A to B then back to A with a minimum of shared edges

How can I define good in a religion that claims no moral authority?

Can undead you have reanimated wait inside a portable hole?

"... to apply for a visa" or "... and applied for a visa"?

Wall plug outlet change

How many people can fit inside Mordenkainen's Magnificent Mansion?

Why can't devices on different VLANs, but on the same subnet, communicate?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

Does Parliament need to approve the new Brexit delay to 31 October 2019?

Semisimplicity of the category of coherent sheaves?

When did F become S in typeography, and why?

Is it ok to offer lower paid work as a trial period before negotiating for a full-time job?

Are my PIs rude or am I just being too sensitive?

Did the UK government pay "millions and millions of dollars" to try to snag Julian Assange?

He got a vote 80% that of Emmanuel Macron’s

Is there a writing software that you can sort scenes like slides in PowerPoint?

What are these Gizmos at Izaña Atmospheric Research Center in Spain?

Did the new image of black hole confirm the general theory of relativity?

Is this wall load bearing? Blueprints and photos attached

Is above average number of years spent on PhD considered a red flag in future academia or industry positions?

University's motivation for having tenure-track positions

Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?

Are spiders unable to hurt humans, especially very small spiders?



How can I automatically replace [[ and ]] with the [LeftDoubleBracket] and [RightDoubleBracket] operators?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Automating Esc [[ Esc formatting?On an existing notebook, how to transform all “double brackets” into “DoubleBracket”Convenient string manipulationHow to define a vector with automatically added symbolic elements with subscriptsHow to convert an image to a compressed string representation equivalent to one copied to clipboard by `CopyToClipboard[image]`?Incorporating Built-In Function Options/Parameters into ShorthandDifferentiating a Dot ProductPostfix Double Slash Notation with Multiple ParametersHow to construct custom operators with precedence?Can symbols like + or * be used to denote the Plus and Times functions?How to efficiently input matrices in Mathematica (compared to what MATLAB offers)Define a new Front End Syntax for Function Argument Checking & Debugging










9












$begingroup$


When you type ->, it is automatically turned into the [Rule] character. Can we configure our frontends to do the same for the [[ and ]] characters, which could be turned into [LeftDoubleBracket] and [RightDoubleBracket]?



You can easily do this manually by typing <esc>[[<esc>, but I would like to do this automatically.



This question was originally asked by me in the chat and has answers there; this question is so that those answers can be added and kept for the community.










share|improve this question











$endgroup$







  • 3




    $begingroup$
    Do you really want that when writing func[func2[arg]]? I changed KeyEventTranslations.tr to have <kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>.
    $endgroup$
    – Coolwater
    Apr 7 at 19:04











  • $begingroup$
    Yes, this is part of the problem. Ideally it would only happen after you have typed the matching [[, but more than likely it needs to be done at shift-enter at the earliest. For [[ the problem is simpler because there is no time when you would type [[ except for as part of a Part expression.
    $endgroup$
    – Carl Lange
    Apr 7 at 19:05







  • 1




    $begingroup$
    closely related: 98175
    $endgroup$
    – Kuba
    Apr 7 at 20:50






  • 1




    $begingroup$
    Related using KeyEventTranslations 5221
    $endgroup$
    – Rohit Namjoshi
    Apr 7 at 21:41










  • $begingroup$
    Unless @Kuba or another mod overrules, I will leave this open as I am asking how to do it as-I-work rather than afterwards, but the questions are certainly strongly related.
    $endgroup$
    – Carl Lange
    Apr 7 at 21:42















9












$begingroup$


When you type ->, it is automatically turned into the [Rule] character. Can we configure our frontends to do the same for the [[ and ]] characters, which could be turned into [LeftDoubleBracket] and [RightDoubleBracket]?



You can easily do this manually by typing <esc>[[<esc>, but I would like to do this automatically.



This question was originally asked by me in the chat and has answers there; this question is so that those answers can be added and kept for the community.










share|improve this question











$endgroup$







  • 3




    $begingroup$
    Do you really want that when writing func[func2[arg]]? I changed KeyEventTranslations.tr to have <kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>.
    $endgroup$
    – Coolwater
    Apr 7 at 19:04











  • $begingroup$
    Yes, this is part of the problem. Ideally it would only happen after you have typed the matching [[, but more than likely it needs to be done at shift-enter at the earliest. For [[ the problem is simpler because there is no time when you would type [[ except for as part of a Part expression.
    $endgroup$
    – Carl Lange
    Apr 7 at 19:05







  • 1




    $begingroup$
    closely related: 98175
    $endgroup$
    – Kuba
    Apr 7 at 20:50






  • 1




    $begingroup$
    Related using KeyEventTranslations 5221
    $endgroup$
    – Rohit Namjoshi
    Apr 7 at 21:41










  • $begingroup$
    Unless @Kuba or another mod overrules, I will leave this open as I am asking how to do it as-I-work rather than afterwards, but the questions are certainly strongly related.
    $endgroup$
    – Carl Lange
    Apr 7 at 21:42













9












9








9


1



$begingroup$


When you type ->, it is automatically turned into the [Rule] character. Can we configure our frontends to do the same for the [[ and ]] characters, which could be turned into [LeftDoubleBracket] and [RightDoubleBracket]?



You can easily do this manually by typing <esc>[[<esc>, but I would like to do this automatically.



This question was originally asked by me in the chat and has answers there; this question is so that those answers can be added and kept for the community.










share|improve this question











$endgroup$




When you type ->, it is automatically turned into the [Rule] character. Can we configure our frontends to do the same for the [[ and ]] characters, which could be turned into [LeftDoubleBracket] and [RightDoubleBracket]?



You can easily do this manually by typing <esc>[[<esc>, but I would like to do this automatically.



This question was originally asked by me in the chat and has answers there; this question is so that those answers can be added and kept for the community.







syntax custom-notation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 7 at 19:01







Carl Lange

















asked Apr 7 at 18:52









Carl LangeCarl Lange

5,29411141




5,29411141







  • 3




    $begingroup$
    Do you really want that when writing func[func2[arg]]? I changed KeyEventTranslations.tr to have <kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>.
    $endgroup$
    – Coolwater
    Apr 7 at 19:04











  • $begingroup$
    Yes, this is part of the problem. Ideally it would only happen after you have typed the matching [[, but more than likely it needs to be done at shift-enter at the earliest. For [[ the problem is simpler because there is no time when you would type [[ except for as part of a Part expression.
    $endgroup$
    – Carl Lange
    Apr 7 at 19:05







  • 1




    $begingroup$
    closely related: 98175
    $endgroup$
    – Kuba
    Apr 7 at 20:50






  • 1




    $begingroup$
    Related using KeyEventTranslations 5221
    $endgroup$
    – Rohit Namjoshi
    Apr 7 at 21:41










  • $begingroup$
    Unless @Kuba or another mod overrules, I will leave this open as I am asking how to do it as-I-work rather than afterwards, but the questions are certainly strongly related.
    $endgroup$
    – Carl Lange
    Apr 7 at 21:42












  • 3




    $begingroup$
    Do you really want that when writing func[func2[arg]]? I changed KeyEventTranslations.tr to have <kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>.
    $endgroup$
    – Coolwater
    Apr 7 at 19:04











  • $begingroup$
    Yes, this is part of the problem. Ideally it would only happen after you have typed the matching [[, but more than likely it needs to be done at shift-enter at the earliest. For [[ the problem is simpler because there is no time when you would type [[ except for as part of a Part expression.
    $endgroup$
    – Carl Lange
    Apr 7 at 19:05







  • 1




    $begingroup$
    closely related: 98175
    $endgroup$
    – Kuba
    Apr 7 at 20:50






  • 1




    $begingroup$
    Related using KeyEventTranslations 5221
    $endgroup$
    – Rohit Namjoshi
    Apr 7 at 21:41










  • $begingroup$
    Unless @Kuba or another mod overrules, I will leave this open as I am asking how to do it as-I-work rather than afterwards, but the questions are certainly strongly related.
    $endgroup$
    – Carl Lange
    Apr 7 at 21:42







3




3




$begingroup$
Do you really want that when writing func[func2[arg]]? I changed KeyEventTranslations.tr to have <kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>.
$endgroup$
– Coolwater
Apr 7 at 19:04





$begingroup$
Do you really want that when writing func[func2[arg]]? I changed KeyEventTranslations.tr to have <kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>.
$endgroup$
– Coolwater
Apr 7 at 19:04













$begingroup$
Yes, this is part of the problem. Ideally it would only happen after you have typed the matching [[, but more than likely it needs to be done at shift-enter at the earliest. For [[ the problem is simpler because there is no time when you would type [[ except for as part of a Part expression.
$endgroup$
– Carl Lange
Apr 7 at 19:05





$begingroup$
Yes, this is part of the problem. Ideally it would only happen after you have typed the matching [[, but more than likely it needs to be done at shift-enter at the earliest. For [[ the problem is simpler because there is no time when you would type [[ except for as part of a Part expression.
$endgroup$
– Carl Lange
Apr 7 at 19:05





1




1




$begingroup$
closely related: 98175
$endgroup$
– Kuba
Apr 7 at 20:50




$begingroup$
closely related: 98175
$endgroup$
– Kuba
Apr 7 at 20:50




1




1




$begingroup$
Related using KeyEventTranslations 5221
$endgroup$
– Rohit Namjoshi
Apr 7 at 21:41




$begingroup$
Related using KeyEventTranslations 5221
$endgroup$
– Rohit Namjoshi
Apr 7 at 21:41












$begingroup$
Unless @Kuba or another mod overrules, I will leave this open as I am asking how to do it as-I-work rather than afterwards, but the questions are certainly strongly related.
$endgroup$
– Carl Lange
Apr 7 at 21:42




$begingroup$
Unless @Kuba or another mod overrules, I will leave this open as I am asking how to do it as-I-work rather than afterwards, but the questions are certainly strongly related.
$endgroup$
– Carl Lange
Apr 7 at 21:42










3 Answers
3






active

oldest

votes


















9












$begingroup$

You can use CellEpilog to modify the contents of the cell upon evaluation:



SetOptions[EvaluationNotebook[],
CellEpilog :> If[
! TrueQ[
Max@CurrentValue[CellChangeTimes] <=
CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"]
],
CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"] =
Max@CurrentValue[CellChangeTimes];
NotebookWrite[
EvaluationCell[],
Replace[NotebookRead[EvaluationCell[]],
RowBox@head_, "[", RowBox@"[", part_, "]", "]" :>
RowBox@head, "[LeftDoubleBracket]", part, "[RightDoubleBracket]", All]
]
]
]


Demonstration:
https://i.stack.imgur.com/4V5WJ.gif



This could of course be extended to do similar replacements for <|…|> etc. To minimize the performance hit, we keep track of the last CellChangeTimes value and only rerun the replacement code when it changed.



The nice thing about an approach like this (i.e. manipulation of the cell's box structure) is that it's rather straightforward to identify the bracket pairs to replace, since the front-end does all the necessary parsing for us.



An alternative to putting the code into CellEpilog might be to create a menu item for it, one could also modify the "Evaluate cells" menu item to run this code on all selected cells first.






share|improve this answer











$endgroup$




















    9












    $begingroup$

    Here is a stylesheet solution modeled after Lucas' answer, except that I use CellEventActions to tie the transformation to a keyboard short cut:



    SetOptions[
    EvaluationNotebook[],
    StyleDefinitions -> Notebook[
    Cell[StyleData[StyleDefinitions->"Default.nb"]],
    Cell[StyleData["Input"],
    CellEventActions ->
    "KeyDown","y" :> If[CurrentValue["ControlKey"],
    NotebookWrite[
    EvaluationCell[],
    With[read=NotebookRead[EvaluationCell[]],
    Cell[
    ReplaceAll[
    First[read],
    RuleDelayed[
    RowBox[head_,"[",RowBox["[",part_,"]"],"]"],
    RowBox[head,"[LeftDoubleBracket]",part,"[RightDoubleBracket]"]
    ]
    ],
    Sequence@@Rest[read]
    ]
    ]
    ];
    SelectionMove[EvaluationNotebook[],Before,CellContents];
    SelectionMove[EvaluationNotebook[],After,CellContents]
    ],
    PassEventsDown->True
    ]
    ,
    StyleDefinitions->"PrivateStylesheetFormatting.nb"
    ]
    ]


    Using the short cut ctrl + y will convert [[ and ]] to the double bracketing bar versions.






    share|improve this answer









    $endgroup$




















      4












      $begingroup$

      It's maybe not exactly what you want but you can always select the cell, expression, or part of it ( Ctrl-. is helpful for this ) and then do Ctrl-Shift-n to change the selection to Standard Form. This includes the changes to [[ and ]] and doesn't require any set up or customisation.






      share|improve this answer









      $endgroup$













        Your Answer








        StackExchange.ready(function()
        var channelOptions =
        tags: "".split(" "),
        id: "387"
        ;
        initTagRenderer("".split(" "), "".split(" "), channelOptions);

        StackExchange.using("externalEditor", function()
        // Have to fire editor after snippets, if snippets enabled
        if (StackExchange.settings.snippets.snippetsEnabled)
        StackExchange.using("snippets", function()
        createEditor();
        );

        else
        createEditor();

        );

        function createEditor()
        StackExchange.prepareEditor(
        heartbeatType: 'answer',
        autoActivateHeartbeat: false,
        convertImagesToLinks: false,
        noModals: true,
        showLowRepImageUploadWarning: true,
        reputationToPostImages: null,
        bindNavPrevention: true,
        postfix: "",
        imageUploader:
        brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
        contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
        allowUrls: true
        ,
        onDemand: true,
        discardSelector: ".discard-answer"
        ,immediatelyShowMarkdownHelp:true
        );



        );













        draft saved

        draft discarded


















        StackExchange.ready(
        function ()
        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194775%2fhow-can-i-automatically-replace-and-with-the-leftdoublebracket-and-ri%23new-answer', 'question_page');

        );

        Post as a guest















        Required, but never shown

























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes









        9












        $begingroup$

        You can use CellEpilog to modify the contents of the cell upon evaluation:



        SetOptions[EvaluationNotebook[],
        CellEpilog :> If[
        ! TrueQ[
        Max@CurrentValue[CellChangeTimes] <=
        CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"]
        ],
        CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"] =
        Max@CurrentValue[CellChangeTimes];
        NotebookWrite[
        EvaluationCell[],
        Replace[NotebookRead[EvaluationCell[]],
        RowBox@head_, "[", RowBox@"[", part_, "]", "]" :>
        RowBox@head, "[LeftDoubleBracket]", part, "[RightDoubleBracket]", All]
        ]
        ]
        ]


        Demonstration:
        https://i.stack.imgur.com/4V5WJ.gif



        This could of course be extended to do similar replacements for <|…|> etc. To minimize the performance hit, we keep track of the last CellChangeTimes value and only rerun the replacement code when it changed.



        The nice thing about an approach like this (i.e. manipulation of the cell's box structure) is that it's rather straightforward to identify the bracket pairs to replace, since the front-end does all the necessary parsing for us.



        An alternative to putting the code into CellEpilog might be to create a menu item for it, one could also modify the "Evaluate cells" menu item to run this code on all selected cells first.






        share|improve this answer











        $endgroup$

















          9












          $begingroup$

          You can use CellEpilog to modify the contents of the cell upon evaluation:



          SetOptions[EvaluationNotebook[],
          CellEpilog :> If[
          ! TrueQ[
          Max@CurrentValue[CellChangeTimes] <=
          CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"]
          ],
          CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"] =
          Max@CurrentValue[CellChangeTimes];
          NotebookWrite[
          EvaluationCell[],
          Replace[NotebookRead[EvaluationCell[]],
          RowBox@head_, "[", RowBox@"[", part_, "]", "]" :>
          RowBox@head, "[LeftDoubleBracket]", part, "[RightDoubleBracket]", All]
          ]
          ]
          ]


          Demonstration:
          https://i.stack.imgur.com/4V5WJ.gif



          This could of course be extended to do similar replacements for <|…|> etc. To minimize the performance hit, we keep track of the last CellChangeTimes value and only rerun the replacement code when it changed.



          The nice thing about an approach like this (i.e. manipulation of the cell's box structure) is that it's rather straightforward to identify the bracket pairs to replace, since the front-end does all the necessary parsing for us.



          An alternative to putting the code into CellEpilog might be to create a menu item for it, one could also modify the "Evaluate cells" menu item to run this code on all selected cells first.






          share|improve this answer











          $endgroup$















            9












            9








            9





            $begingroup$

            You can use CellEpilog to modify the contents of the cell upon evaluation:



            SetOptions[EvaluationNotebook[],
            CellEpilog :> If[
            ! TrueQ[
            Max@CurrentValue[CellChangeTimes] <=
            CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"]
            ],
            CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"] =
            Max@CurrentValue[CellChangeTimes];
            NotebookWrite[
            EvaluationCell[],
            Replace[NotebookRead[EvaluationCell[]],
            RowBox@head_, "[", RowBox@"[", part_, "]", "]" :>
            RowBox@head, "[LeftDoubleBracket]", part, "[RightDoubleBracket]", All]
            ]
            ]
            ]


            Demonstration:
            https://i.stack.imgur.com/4V5WJ.gif



            This could of course be extended to do similar replacements for <|…|> etc. To minimize the performance hit, we keep track of the last CellChangeTimes value and only rerun the replacement code when it changed.



            The nice thing about an approach like this (i.e. manipulation of the cell's box structure) is that it's rather straightforward to identify the bracket pairs to replace, since the front-end does all the necessary parsing for us.



            An alternative to putting the code into CellEpilog might be to create a menu item for it, one could also modify the "Evaluate cells" menu item to run this code on all selected cells first.






            share|improve this answer











            $endgroup$



            You can use CellEpilog to modify the contents of the cell upon evaluation:



            SetOptions[EvaluationNotebook[],
            CellEpilog :> If[
            ! TrueQ[
            Max@CurrentValue[CellChangeTimes] <=
            CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"]
            ],
            CurrentValue[EvaluationCell[], TaggingRules, "autoreplaceTime"] =
            Max@CurrentValue[CellChangeTimes];
            NotebookWrite[
            EvaluationCell[],
            Replace[NotebookRead[EvaluationCell[]],
            RowBox@head_, "[", RowBox@"[", part_, "]", "]" :>
            RowBox@head, "[LeftDoubleBracket]", part, "[RightDoubleBracket]", All]
            ]
            ]
            ]


            Demonstration:
            https://i.stack.imgur.com/4V5WJ.gif



            This could of course be extended to do similar replacements for <|…|> etc. To minimize the performance hit, we keep track of the last CellChangeTimes value and only rerun the replacement code when it changed.



            The nice thing about an approach like this (i.e. manipulation of the cell's box structure) is that it's rather straightforward to identify the bracket pairs to replace, since the front-end does all the necessary parsing for us.



            An alternative to putting the code into CellEpilog might be to create a menu item for it, one could also modify the "Evaluate cells" menu item to run this code on all selected cells first.







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 7 at 21:41

























            answered Apr 7 at 21:36









            Lukas LangLukas Lang

            7,21511032




            7,21511032





















                9












                $begingroup$

                Here is a stylesheet solution modeled after Lucas' answer, except that I use CellEventActions to tie the transformation to a keyboard short cut:



                SetOptions[
                EvaluationNotebook[],
                StyleDefinitions -> Notebook[
                Cell[StyleData[StyleDefinitions->"Default.nb"]],
                Cell[StyleData["Input"],
                CellEventActions ->
                "KeyDown","y" :> If[CurrentValue["ControlKey"],
                NotebookWrite[
                EvaluationCell[],
                With[read=NotebookRead[EvaluationCell[]],
                Cell[
                ReplaceAll[
                First[read],
                RuleDelayed[
                RowBox[head_,"[",RowBox["[",part_,"]"],"]"],
                RowBox[head,"[LeftDoubleBracket]",part,"[RightDoubleBracket]"]
                ]
                ],
                Sequence@@Rest[read]
                ]
                ]
                ];
                SelectionMove[EvaluationNotebook[],Before,CellContents];
                SelectionMove[EvaluationNotebook[],After,CellContents]
                ],
                PassEventsDown->True
                ]
                ,
                StyleDefinitions->"PrivateStylesheetFormatting.nb"
                ]
                ]


                Using the short cut ctrl + y will convert [[ and ]] to the double bracketing bar versions.






                share|improve this answer









                $endgroup$

















                  9












                  $begingroup$

                  Here is a stylesheet solution modeled after Lucas' answer, except that I use CellEventActions to tie the transformation to a keyboard short cut:



                  SetOptions[
                  EvaluationNotebook[],
                  StyleDefinitions -> Notebook[
                  Cell[StyleData[StyleDefinitions->"Default.nb"]],
                  Cell[StyleData["Input"],
                  CellEventActions ->
                  "KeyDown","y" :> If[CurrentValue["ControlKey"],
                  NotebookWrite[
                  EvaluationCell[],
                  With[read=NotebookRead[EvaluationCell[]],
                  Cell[
                  ReplaceAll[
                  First[read],
                  RuleDelayed[
                  RowBox[head_,"[",RowBox["[",part_,"]"],"]"],
                  RowBox[head,"[LeftDoubleBracket]",part,"[RightDoubleBracket]"]
                  ]
                  ],
                  Sequence@@Rest[read]
                  ]
                  ]
                  ];
                  SelectionMove[EvaluationNotebook[],Before,CellContents];
                  SelectionMove[EvaluationNotebook[],After,CellContents]
                  ],
                  PassEventsDown->True
                  ]
                  ,
                  StyleDefinitions->"PrivateStylesheetFormatting.nb"
                  ]
                  ]


                  Using the short cut ctrl + y will convert [[ and ]] to the double bracketing bar versions.






                  share|improve this answer









                  $endgroup$















                    9












                    9








                    9





                    $begingroup$

                    Here is a stylesheet solution modeled after Lucas' answer, except that I use CellEventActions to tie the transformation to a keyboard short cut:



                    SetOptions[
                    EvaluationNotebook[],
                    StyleDefinitions -> Notebook[
                    Cell[StyleData[StyleDefinitions->"Default.nb"]],
                    Cell[StyleData["Input"],
                    CellEventActions ->
                    "KeyDown","y" :> If[CurrentValue["ControlKey"],
                    NotebookWrite[
                    EvaluationCell[],
                    With[read=NotebookRead[EvaluationCell[]],
                    Cell[
                    ReplaceAll[
                    First[read],
                    RuleDelayed[
                    RowBox[head_,"[",RowBox["[",part_,"]"],"]"],
                    RowBox[head,"[LeftDoubleBracket]",part,"[RightDoubleBracket]"]
                    ]
                    ],
                    Sequence@@Rest[read]
                    ]
                    ]
                    ];
                    SelectionMove[EvaluationNotebook[],Before,CellContents];
                    SelectionMove[EvaluationNotebook[],After,CellContents]
                    ],
                    PassEventsDown->True
                    ]
                    ,
                    StyleDefinitions->"PrivateStylesheetFormatting.nb"
                    ]
                    ]


                    Using the short cut ctrl + y will convert [[ and ]] to the double bracketing bar versions.






                    share|improve this answer









                    $endgroup$



                    Here is a stylesheet solution modeled after Lucas' answer, except that I use CellEventActions to tie the transformation to a keyboard short cut:



                    SetOptions[
                    EvaluationNotebook[],
                    StyleDefinitions -> Notebook[
                    Cell[StyleData[StyleDefinitions->"Default.nb"]],
                    Cell[StyleData["Input"],
                    CellEventActions ->
                    "KeyDown","y" :> If[CurrentValue["ControlKey"],
                    NotebookWrite[
                    EvaluationCell[],
                    With[read=NotebookRead[EvaluationCell[]],
                    Cell[
                    ReplaceAll[
                    First[read],
                    RuleDelayed[
                    RowBox[head_,"[",RowBox["[",part_,"]"],"]"],
                    RowBox[head,"[LeftDoubleBracket]",part,"[RightDoubleBracket]"]
                    ]
                    ],
                    Sequence@@Rest[read]
                    ]
                    ]
                    ];
                    SelectionMove[EvaluationNotebook[],Before,CellContents];
                    SelectionMove[EvaluationNotebook[],After,CellContents]
                    ],
                    PassEventsDown->True
                    ]
                    ,
                    StyleDefinitions->"PrivateStylesheetFormatting.nb"
                    ]
                    ]


                    Using the short cut ctrl + y will convert [[ and ]] to the double bracketing bar versions.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Apr 9 at 7:42









                    Carl WollCarl Woll

                    73.7k398192




                    73.7k398192





















                        4












                        $begingroup$

                        It's maybe not exactly what you want but you can always select the cell, expression, or part of it ( Ctrl-. is helpful for this ) and then do Ctrl-Shift-n to change the selection to Standard Form. This includes the changes to [[ and ]] and doesn't require any set up or customisation.






                        share|improve this answer









                        $endgroup$

















                          4












                          $begingroup$

                          It's maybe not exactly what you want but you can always select the cell, expression, or part of it ( Ctrl-. is helpful for this ) and then do Ctrl-Shift-n to change the selection to Standard Form. This includes the changes to [[ and ]] and doesn't require any set up or customisation.






                          share|improve this answer









                          $endgroup$















                            4












                            4








                            4





                            $begingroup$

                            It's maybe not exactly what you want but you can always select the cell, expression, or part of it ( Ctrl-. is helpful for this ) and then do Ctrl-Shift-n to change the selection to Standard Form. This includes the changes to [[ and ]] and doesn't require any set up or customisation.






                            share|improve this answer









                            $endgroup$



                            It's maybe not exactly what you want but you can always select the cell, expression, or part of it ( Ctrl-. is helpful for this ) and then do Ctrl-Shift-n to change the selection to Standard Form. This includes the changes to [[ and ]] and doesn't require any set up or customisation.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Apr 10 at 6:11









                            John JowettJohn Jowett

                            1817




                            1817



























                                draft saved

                                draft discarded
















































                                Thanks for contributing an answer to Mathematica Stack Exchange!


                                • Please be sure to answer the question. Provide details and share your research!

                                But avoid


                                • Asking for help, clarification, or responding to other answers.

                                • Making statements based on opinion; back them up with references or personal experience.

                                Use MathJax to format equations. MathJax reference.


                                To learn more, see our tips on writing great answers.




                                draft saved


                                draft discarded














                                StackExchange.ready(
                                function ()
                                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f194775%2fhow-can-i-automatically-replace-and-with-the-leftdoublebracket-and-ri%23new-answer', 'question_page');

                                );

                                Post as a guest















                                Required, but never shown





















































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown

































                                Required, but never shown














                                Required, but never shown












                                Required, but never shown







                                Required, but never shown







                                Popular posts from this blog

                                រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

                                QGIS export composer to PDF scale the map [closed] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Print Composer QGIS 2.6, how to export image?QGIS 2.8.1 print composer won't export all OpenCycleMap base layer tilesSave Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?Export QGIS Print Composer PDF with searchable text labelsQGIS Print Composer does not change from landscape to portrait orientation?How can I avoid map size and scale changes in print composer?Fuzzy PDF export in QGIS running on macSierra OSExport the legend into its 100% size using Print ComposerScale-dependent rendering in QGIS PDF output

                                PDF-ში გადმოწერა სანავიგაციო მენიუproject page