As of version 12.3, this behaviour is now introduced as the default, governed by the AutoOperatorRenderings
setting. It now works quite like "programming ligatures" in other IDEs and text editors, in that when you type [[
, \[LeftDoubleBracket]
is displayed, but when you edit it (for example by hitting backspace), the actual typed characters are modified - basically, just as ->
and \[Rule]
.
From the 12.3 announcement blog:
It might seem odd that it’s taken so many years to go from “automatic →” to “automatic 〚 〛”. But it’s a lot more subtle than you might think, and in fact it’s required a whole new as-you-type approach to code rendering. Back in Version 3.0, the idea was to replace -> with → when you type it. So, for example, if you then backspace one character, you’ll delete the whole →, rather than simply “removing the >” and reverting to -.
But if you’re dealing with [[ ... ]] you can’t just do this kind of “local replacement” without the potential for confusion with some ]] showing up as 〛 while others break apart into ]] as a result of routine editing.
In Version 12.3 what we’re doing is not to make replacements at all, but instead just to render specified sequences of characters (like ]]) in special ways. The result is that we can support very general “ligature-like” behavior, and that backspacing will always exactly reverse characters that were entered.
Which seems like a bit of a Wolfram-y way to describe a feature that's been in text editing at large for at least 30 years, with standard ligatures like "fi", and in programming text editors for programming-specific use cases for probably the last ten or so, becoming quite popular with fonts like Fira Code.
(Actually, to be fair, there's some semantic parsing cleverness going on with regard to ]]
working correctly at the end of a Part
expression, and not replacing at the end of a bunch of function calls.)
Anyway, it's nice to see this as the default behaviour now - I find my code significantly easier to read in this way.
func[func2[arg]]
? I changed KeyEventTranslations.tr to have<kbd>Alt gr</kbd>+<kbd>i</kbd>/<kbd>o</kbd>
. $\endgroup$[[
, 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 aPart
expression. $\endgroup$