12
$\begingroup$

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?

$\endgroup$
5
  • $\begingroup$ I assume that Shift + 8 produces "*"; in that case, it starts a bulleted list. Does Undo (CTRL + Z) help? If not, search "keyboard shortcut" in this site for some pointers. $\endgroup$
    – MarcoB
    Dec 18, 2023 at 2:19
  • $\begingroup$ What you get is a Shift+Ctrl+8 input window as a local Box eg for Matrix in traditional form. Depends on the keyboad, language for windows and Mathematica. See $$C:\Program Files\Wolfram Research\Mathematica\13.3\SystemFiles\FrontEnd\TextResources\Windows\KeyEventTranslations.tr$$ for the key events with an $8$ and change its Modifier $\endgroup$
    – Roland F
    Dec 18, 2023 at 13:21
  • 5
    $\begingroup$ I see this question has a few close votes, but I disagree. This is a functionality of Mathematica that's that's poorly documented, making this a useful question for other people. The question phrasing could do with a bit of clarification though. $\endgroup$ Dec 18, 2023 at 14:19
  • $\begingroup$ It might be nice to see a more generalized version of this question that could manage for any given erroneous key press (I’m looking at you, F1) or accidental shortcut/mapping activation which one wants to avoid. Some features may be built in & could be addressed through menus, others like this question may not be. $\endgroup$ Dec 18, 2023 at 14:22
  • 4
    $\begingroup$ I am also unsure why the question is attracting close votes, particularly under the "needs consultant or Wolfram support" and "needs clarity" categories. I find the question very clear and reproducible, and the desired outcome just as clear. There are also plenty of questions on keyboard shortcuts / non-menu command entry on this site, so it appears on topic to me. I voted not to close it, and would recommend that it be kept open. $\endgroup$
    – MarcoB
    Dec 18, 2023 at 15:58

2 Answers 2

13
$\begingroup$

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.

enter image description here

Edit

If you can't edit the default stylesheet, you can create a new one 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.

$\endgroup$
7
  • $\begingroup$ Apologies, this answer is very detailed but I am still stumbling at the final step; I get exactly to what is displayed on your image but I can't seem to actually edit anything (i.e. I can't delete/edit that portion of the text). There is a message above that says "Make modifications to any definition using commands in the Format menu" but I don't see any commands there that seem relevant for editing/deleting text. $\endgroup$
    – user297024
    Dec 18, 2023 at 16:38
  • $\begingroup$ Modifying Default.nb is generally considered a "bad idea". The preferred method would be to create a custom stylesheet and override the Input style. $\endgroup$
    – ihojnicki
    Dec 18, 2023 at 16:45
  • 2
    $\begingroup$ you can try SetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], Cell[StyleData["Input"], StyleKeyMapping -> {"=" -> "WolframAlphaShort"}]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]] $\endgroup$
    – kglr
    Dec 18, 2023 at 16:49
  • 1
    $\begingroup$ or StyleKeyMapping ->{} to remove all to remove all short-cuts associated with Input cells. $\endgroup$
    – kglr
    Dec 18, 2023 at 16:50
  • $\begingroup$ @ihojnicki Not sure I would agree. Default.nb inherits form Core.nb. I'd say that Default.nb would be the place for a user to tinker with their own preferences while Core.nb would be the "hands off" territory. That said: making your own stylesheet is definitely the safe way to do it. $\endgroup$ Dec 18, 2023 at 16:57
7
$\begingroup$

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:

  1. Create a new style file "NoItems.nb"

  2. 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"
        ]
    ] 
    
  3. 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"]
    
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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