7
$\begingroup$

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.

$\endgroup$
5
  • $\begingroup$ 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. $\endgroup$
    – thorimur
    Aug 26, 2021 at 0:26
  • 1
    $\begingroup$ try if SetOptions[EvaluationNotebook[], StyleDefinitions -> Notebook[{Cell[StyleData[StyleDefinitions -> "Default.nb"]], Cell[StyleData["Input"], StyleKeyMapping -> {"=" -> "WolframAlphaShort", "*" -> "Item"}]}, StyleDefinitions -> "PrivateStylesheetFormatting.nb"]] works. $\endgroup$
    – kglr
    Aug 27, 2021 at 8:44
  • $\begingroup$ @kglr thanks, that works! I'll accept it as an answer if you like. (It also addresses thorimur's comment if you remove "=" -> "WolframAlphaShort",). $\endgroup$
    – user108903
    Aug 27, 2021 at 13:55
  • $\begingroup$ @kglr is there a way to set this in all notebooks every time I run mathematica? $\endgroup$
    – user108903
    Aug 27, 2021 at 14:06
  • $\begingroup$ @user108903, posted the comment as an answer. $\endgroup$
    – kglr
    Aug 27, 2021 at 14:15

3 Answers 3

10
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ How to remove style definitions in all notebook, not only EvaluationNotebook? I was searching this option in Option Inspector but didn't find. $\endgroup$
    – Lechuu
    Jan 17 at 11:42
1
$\begingroup$

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?

$\endgroup$
0
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ 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. $\endgroup$
    – user108903
    Aug 27, 2021 at 7:35

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.