7

I am using version 12.1.1.0 on OS X 10.13.

Every so often, a Python interpreter cell appears:

python interpreter cell

I think I am probably summoning it by inadvertently pressing ">" (due to clumsy typing). Or maybe some other keyboard shortcut which I haven't discovered is to blame.

Before the interpreter cell appears it often causes a beachball for several seconds, and I find it annoying.

Can I disable the interpreter?

Can I disable all keyboard shortcuts which summon it?

For context, this question discusses the interpreter and the keyboard shortcut, but doesn't address how to disable them.

user108903
  • 183
  • 5
  • I also feel like this should be able to be disabled in preferences, as should = summoning Wolfram|Alpha. I'm sure there's a way...not sure why this question has 2 close votes, though. – thorimur Aug 26 '21 at 00:26
  • 1
    try if SetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], Cell[StyleData["Input"], StyleKeyMapping -> {"=" -> "WolframAlphaShort", "*" -> "Item"}]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]] works. – kglr Aug 27 '21 at 08:44
  • @kglr thanks, that works! I'll accept it as an answer if you like. (It also addresses thorimur's comment if you remove "=" -> "WolframAlphaShort",). – user108903 Aug 27 '21 at 13:55
  • @kglr is there a way to set this in all notebooks every time I run mathematica? – user108903 Aug 27 '21 at 14:06
  • @user108903, posted the comment as an answer. – kglr Aug 27 '21 at 14:15

3 Answers3

10

The short-cut > at the beginning of a line to start an external code cell is set as part of style definitions for Input cells:

CurrentValue[{StyleDefinitions, "Input", StyleKeyMapping}]
{"=" -> "WolframAlphaShort", "*" -> "Item", ">" -> "ExternalLanguage"}

You can modify the style definitions and remove ">" -> "ExternalLanguage" to disable this short-cut:

SetOptions[EvaluationNotebook[],   
  StyleDefinitions -> 
    Notebook[
     {Cell[StyleData[StyleDefinitions -> "Default.nb"]],      
      Cell[StyleData["Input"], 
        StyleKeyMapping -> {"=" -> "WolframAlphaShort", "*" -> "Item"}]},     
  StyleDefinitions -> "PrivateStylesheetFormatting.nb"]]

Use StyleKeyMapping -> {} to remove all short-cuts associated with Input cells.

kglr
  • 394,356
  • 18
  • 477
  • 896
  • How to remove style definitions in all notebook, not only EvaluationNotebook? I was searching this option in Option Inspector but didn't find. – Lechuu Jan 17 '24 at 11:42
1

For future reference, this is how to remove the shortcut by default in all new notebooks.

  1. Evaluate

    CreateDocument@Notebook[{
      Cell[StyleData[StyleDefinitions -> "Default.nb"]], 
      Cell[StyleData["Input"], 
           StyleKeyMapping -> {"=" -> "WolframAlphaShort", "*" -> "Item"}]
      }, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]
    
  2. Save the resulting notebook to $UserBaseDirectory/SystemFiles/FrontEnd/Stylesheets/MyDefault.nb.

  3. In Format>Option Inspector, choose Global Preferences and then search for DefaultStyleDefinitions and set it to "MyDefault.nb".

  4. Restart Mathematica.

Sources: @kglr's answer, Quickly editing the stylesheet and saving it and How do I change my default stylesheet in Mathematica?

user108903
  • 183
  • 5
0

Here is a solution:

Download Autohotkey.exe from https://www.autohotkey.com/ Then make a script file , put it on the desktop.I call it disableWolfram.ahk. It has two lines, one for each use case mentioned above.

^>::return
^=::return

Basically this script is disabling Ctrl > and Ctrl =. Start Mathematica and then double click on the script. Keys have been disabled. For a more animated version:

^>::return
^=::
Send "You shall not pass"
return

enter image description here

My apologies: I haven't looked into Linux/Mac offerings as I am not working on those systems.

Syed
  • 52,495
  • 4
  • 30
  • 85
  • Thanks for the idea. On OS X at least, the shortcut is just ">", in certain circumstances (e.g., between cells, at the start of a new cell), not "Control+>". So I don't think key remapping will work. – user108903 Aug 27 '21 at 07:35