As at version 3.1, Thonny lacks the GUI for changing commands' keyboard shortcuts, but if you really want, you can change shortcuts by editing the configuration file manually.
Let's say you want to change the shortcut for "Run => Run current script" to Ctrl+E
(I know, Ctrl+R
would be more suitable, but it wouldn't suit as an example because this command already has Ctrl+R
as its alternative shortcut. I know, hidden alternative shortcuts may not be the best idea - maybe I'll get rid of these in the future).
Anyway, in order to make Thonny run the current script using Ctrl+E
follow these steps:
- From the Thonny "Tools" menu select "Open Thonny data folder ..."
- Close Thonny (otherwise your manual changes will be overwritten when Thonny gets closed later)
- Open configuration.ini from the data folder in a text editor.
- If the section
[shortcuts]
is missing, then add it to the end of the configuration file. - Under
[shortcuts]
add following line:run_current_script = <Control-e>
. - Save the configuration file.
- Open Thonny
- Enjoy your new shortcut.
Let's analyze run_current_script = <Control-e>
. The left part is the command id and right part is Tkinter event sequence.
In order to find what command ids are available, you need to search the codebase for ".add_command". Command id is the first argument to this call.
The event sequence usually consists of a modifier (eg. Alt
, Control
, Command
) and a letter or a special key. nb! If you don't want to include Shift
in the shortcut then write the letter in lowercase. Thonny takes care of proper presentation of the shortcut in menu items.