A pet peeve of mine is the use of double square brackets for Part
rather than the single character \[LeftDoubleBracket]
and \[RightDoubleBracket]
. I would like to have these automatically replaced when pasting plain-text code (from StackOverflow for example) into a Mathematica Notebook. I have been unable to configure this.
Can it be done with ImportAutoReplacements
or another automatic method (preferred), or will I need use a method like the "Paste Tabular Data Palette" referenced here?
Either way, I am not good with string parsing, and I want to learn the best way to handle bracket counting.
Sjoerd gave Defer
and Simon gave Ctrl+Shift+N which both cause Mathematica to auto-format code. These are fine options.
I am still interested in a method that is automatic and/or preserves as much of the original code as possible. For example, maintaining prefix f@1
, infix 1 ~f~ 2
, and postfix 1 // f
functions in their original forms.
A subsection of this question was reposted as Matching brackets in a string and received several good answers.