Every once in a while when editing a formula, I want to add a parenthesis at the beginning of the line by pressing Shift9 to get (. However, I will accidentally press Shift8 instead, which stands for *, and the whole line gets converted to some weird rich text with a small solid red square at the beginning of the line.
I don't know what that is for, but I never want to do it and I want to disable whatever is going on; it effectively means I have to delete the line and start again because I don't know how to undo it. In fact it's happened for a long time and I've only just figured out what was actually happening. I tried looking at keyboard shortcuts online but didn't find anything for Shift8. Note that this only happens at the beginning of the line.
How can I disable this keyboard shortcut?
ACCEPTED]
Surprisingly, this behavior is not actually a keyboard shortcut as such. It's a style property for Input cells. To disable it, go to the menu Format -> Edit Stylesheet... and then open the Default.nb stylesheet that the current stylesheet is inheriting from. Then, use Ctrl + F (or whatever shortcut your OS uses for that) to search for to style definition of Input cells. Select the cell and press Ctrl + Shift + E (or use Cell -> Show Expression from the menu) to convert the cell to box from. You'll see the line "*" -> "Item" under StyleKeyMapping. If you delete that (or just delete the entire StyleKeyMapping rule), Input cells should no longer get converted to Item cells when you start with them with a *.
Also note that you can actually define your own shortcuts for different cell types with this mechanism.
If you can't edit the default stylesheet, you can create a new one [1] that overrides the default Input style and link that stylesheet to your notebook. I'm looking for an easier solution, so I might update this answer later.
[1] http://reference.wolfram.com/language/tutorial/WorkingWithStylesheets.htmlSetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], Cell[StyleData["Input"], StyleKeyMapping -> {"=" -> "WolframAlphaShort"}]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]] - kglr
StyleKeyMapping ->{} to remove all to remove all short-cuts associated with Input cells. - kglr
Some extra tips to anyone in my position (including future me):
I was unable to make any edits to Default.nb (or any style file at all) using Mathematica's own "Edit Stylesheet" functions. I could edit (a copy of) the file directly using vi, but then Mathematica gave a rude beep whenever I used that file saying it had been edited outside Mathematica (sigh).
However, I was able to:
Create a new style file "NoItems.nb"
Edit the style file from the mathematica prompt, using kgir's suggestion in the comments:
SetOptions[
EvaluationNotebook[],
StyleDefinitions ->
Notebook[
{
Cell[StyleData[StyleDefinitions -> "Default.nb"]],
Cell[StyleData["Input"],
StyleKeyMapping -> {"=" -> "WolframAlphaShort"}]
},
StyleDefinitions -> "NoItems.nb"
]
]
Make that the default style using the answer here (https://stackoverflow.com/questions/61337720/mathematica-how-to-set-default-stylesheet) by typing:
SetOptions[$FrontEnd, DefaultStyleDefinitions -> "NoItems.nb"]
Ctrl-Shift-E to see the underlying cell definitions to edit - b3m2a1