11
$\begingroup$

I just updated to Mathematica 12.3.1. Whenever I use the double square brackets used to specify Part, Mathematica now auto-formats them. While the readability is nice, when I go to edit the code, I keep "missing" the place I want to edit because Mathematica expands the auto-formatted double square brackets to regular double brackets and now my cursor is in the wrong spot. How do I keep Mathematica from auto-formatting double square brackets? Is it an option somewhere in preferences that I'm just not seeing?

I want this

mylist[[i]]

instead of this

mylist〚i〛
$\endgroup$
3

2 Answers 2

8
$\begingroup$

The new behavior of using ligatures for certain textual forms is controlled by this front end setting:

In[24]:= CurrentValue[$FrontEnd, {StyleHints, "OperatorRenderings"}]

Out[24]= <|"|->" -> "\[Function]", "->" -> "\[Rule]", 
 ":>" -> "\[RuleDelayed]", "<=" -> "\[LessEqual]", 
 ">=" -> "\[GreaterEqual]", "!=" -> "\[NotEqual]", "==" -> "\[Equal]",
  "<->" -> "\[TwoWayRule]", "[[" -> "\[LeftDoubleBracket]", 
 "]]" -> "\[RightDoubleBracket]", "<|" -> "\[LeftAssociation]", 
 "|>" -> "\[RightAssociation]"|>

To remove only the double square bracket formatting you can use

With[
    {orig = CurrentValue[$FrontEnd, {StyleHints, "OperatorRenderings"}]},
    CurrentValue[$FrontEnd, {StyleHints, "OperatorRenderings"}] = KeyDrop[orig, {"[[", "]]"}]
]

or to disable all ligatures use

CurrentValue[$FrontEnd, {StyleHints, "OperatorRenderings"}] = {}
$\endgroup$
7
  • 1
    $\begingroup$ Interestingly, on my machine (v12.3.1.0 Win 10, 64-bit) the current value is Inherited. Any idea where I can set the parent from which notebooks actually inherit the default values? $\endgroup$ Oct 25, 2021 at 12:39
  • $\begingroup$ @IstvánZachar, I might have made some change in my FE settings at one point. If the code I posted here doesn't work for everyone it isn't as useful as I had thought. $\endgroup$
    – Jason B.
    Oct 25, 2021 at 13:36
  • $\begingroup$ I think your answer is a general and nice solution. It is probably my setup that digresses from default settings: Inherited causes no rendering at all. Actually, your answer helped me, as it shows how to set any value for stylehints, like {}, explicit default list, or any custom association of operator renderings (I prefer rendered arrows but not brackets). $\endgroup$ Oct 25, 2021 at 17:58
  • $\begingroup$ I think this should be a simple menu option, not a complex set of commands to put things back the way they worked before $\endgroup$
    – John McGee
    Oct 26, 2021 at 23:23
  • $\begingroup$ I get Inherited in Wolfram Cloud too, and can't overwrite it's value. $\endgroup$
    – rhermans
    Oct 27, 2021 at 15:37
4
$\begingroup$

I am running version 12.3.1 for Linux x86 (64-bit) (June 24, 2021). The answer by @JasonB using the Association formulation did not work for me. I deleted the "[[" and "]]" keys as shown, but all operator renderings remained. Wolfram Support told me to use a List instead of an Association, and now I can add or delete any operator rendering at will. For example,

CurrentValue[$FrontEnd, {StyleHints, "OperatorRenderings"}] =
   {"|->" -> "\[Function]",
    "->" -> "\[Rule]",
    ":>" -> "\[RuleDelayed]",
    "<=" -> "\[LessEqual]",
    ">=" -> "\[GreaterEqual]",
    "!=" -> "\[NotEqual]",
    "==" -> "\[Equal]",
    "<->" -> "\[TwoWayRule]",
    "<|" -> "\[LeftAssociation]",
    "|>" -> "\[RightAssociation]"
  }
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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