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

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

                                Crop image to path created in TikZ? Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Crop an inserted image?TikZ pictures does not appear in posterImage behind and beyond crop marks?Tikz picture as large as possible on A4 PageTransparency vs image compression dilemmaHow to crop background from image automatically?Image does not cropTikzexternal capturing crop marks when externalizing pgfplots?How to include image path that contains a dollar signCrop image with left size given

                                Romeo and Juliet ContentsCharactersSynopsisSourcesDate and textThemes and motifsCriticism and interpretationLegacyScene by sceneSee alsoNotes and referencesSourcesExternal linksNavigation menu"Consumer Price Index (estimate) 1800–"10.2307/28710160037-3222287101610.1093/res/II.5.31910.2307/45967845967810.2307/2869925286992510.1525/jams.1982.35.3.03a00050"Dada Masilo: South African dancer who breaks the rules"10.1093/res/os-XV.57.1610.2307/28680942868094"Sweet Sorrow: Mann-Korman's Romeo and Juliet Closes Sept. 5 at MN's Ordway"the original10.2307/45957745957710.1017/CCOL0521570476.009"Ram Leela box office collections hit massive Rs 100 crore, pulverises prediction"Archived"Broadway Revival of Romeo and Juliet, Starring Orlando Bloom and Condola Rashad, Will Close Dec. 8"Archived10.1075/jhp.7.1.04hon"Wherefore art thou, Romeo? To make us laugh at Navy Pier"the original10.1093/gmo/9781561592630.article.O006772"Ram-leela Review Roundup: Critics Hail Film as Best Adaptation of Romeo and Juliet"Archived10.2307/31946310047-77293194631"Romeo and Juliet get Twitter treatment""Juliet's Nurse by Lois Leveen""Romeo and Juliet: Orlando Bloom's Broadway Debut Released in Theaters for Valentine's Day"Archived"Romeo and Juliet Has No Balcony"10.1093/gmo/9781561592630.article.O00778110.2307/2867423286742310.1076/enst.82.2.115.959510.1080/00138380601042675"A plague o' both your houses: error in GCSE exam paper forces apology""Juliet of the Five O'Clock Shadow, and Other Wonders"10.2307/33912430027-4321339124310.2307/28487440038-7134284874410.2307/29123140149-661129123144728341M"Weekender Guide: Shakespeare on The Drive""balcony"UK public library membership"romeo"UK public library membership10.1017/CCOL9780521844291"Post-Zionist Critique on Israel and the Palestinians Part III: Popular Culture"10.2307/25379071533-86140377-919X2537907"Capulets and Montagues: UK exam board admit mixing names up in Romeo and Juliet paper"Istoria Novellamente Ritrovata di Due Nobili Amanti2027/mdp.390150822329610820-750X"GCSE exam error: Board accidentally rewrites Shakespeare"10.2307/29176390149-66112917639"Exam board apologises after error in English GCSE paper which confused characters in Shakespeare's Romeo and Juliet""From Mariotto and Ganozza to Romeo and Guilietta: Metamorphoses of a Renaissance Tale"10.2307/37323537323510.2307/2867455286745510.2307/28678912867891"10 Questions for Taylor Swift"10.2307/28680922868092"Haymarket Theatre""The Zeffirelli Way: Revealing Talk by Florentine Director""Michael Smuin: 1938-2007 / Prolific dance director had showy career"The Life and Art of Edwin BoothRomeo and JulietRomeo and JulietRomeo and JulietRomeo and JulietEasy Read Romeo and JulietRomeo and Julieteeecb12003684p(data)4099369-3n8211610759dbe00d-a9e2-41a3-b2c1-977dd692899302814385X313670221313670221