Sublime Text3 is configured to run the python shortcut key in an interactive environment. sublimepython
Install plug-ins
It feels good to write code under Sublime Text3, But I encountered some problems when writing Python.
Use Sublime Text3 to open the python file, or write the python code under Sublime Text3. Run the shortcut key ctrl + B. The running result is displayed below the current window. For example
print("hello world!")
However, if an interactive function such as input is used, an error occurs when ctrl + B is run.
print("hello world!")x = input("please input a string :")print(x)
Running result
This problem can be solved by installing a plug-in sublimeREPL.
If you have installed the Package ManagerHereIn the "Installation Package Manager" section), press ctrl + shift + p to call out an input box, enter Install Package, press enter, and enter SublimeREPL in the new input box, in the following selection list, press enter to start installation. Generally, the installation can be completed in a few seconds.
Click tools> sublimeREPL> python run current file in the top menu bar on the python file interface. A new window will pop up just like IDLE, it is interactive and can be input
Set shortcuts
But every time you choose tools-> sublimeREPL-> python run current file, it is a headache to think about whether to set a shortcut key to run. Because I used to write python Using IDLE, I plan to run it with F5.
We know that Sublime Text is set through the json file. You can open preferences-> Key Binding-Default to see the setting of the original shortcut Key, which is in json format.
Open preferences-> Key Binding-User, and rewrite the relevant properties of the shortcut Key according to the preceding format to overwrite the default settings.
However, the format is not easy to understand. For more information, seeUnofficial documentation
You can set "command" to "run_macro_file" and "args" to the file name of the recording macro to quickly call this macro. But this attempt failed, probably because
Note that the macro buffer will remember only the latest recorded macro. Also, macros only record commands sent to the buffer: window-level commands, such creating a new file, will be ignored.
Macros cannot create new windows.
After a long time, I found related content on the Internet and found a solution.