I was learning python recently, and I have been using notepad++ as an editor before. I stumbled upon VScode and was attracted by its beauty. After using it, I found that it starts quickly and has rich plug-ins. After downloading and installing, it can be used directly without any configuration, and it also supports markdown. Of course, the main thing is to look good :p
Effect picture:
Install the python plugin
- Open VScode, Ctrl+p
- Enter "ext install python", the search time may be longer
- Select the plug-in with the highest download volume and click to install (according to the network situation, the installation time is uncertain, I installed it for a long time, I have already downloaded it here, so it shows uninstall)
At this point, VScode can edit the python code. After editing the code, press F5 to run it. The first run will let you choose the environment, just choose python.
By default, you need to press F5 again to run the program after pressing F5. If you want to press F5 to run immediately, you need to change "stopOnEntry": true in the launch.json file to "stopOnEntry": false.
Recommend a plugin, vscode-icons can make the resource manager on the left side of VScode display icons according to the file type
configure flake8
After installing flake8, when writing code, the editor will prompt where is the error, and the code format is not standardized.
- open command line
- Type "pip install flake8"
- After installing flake8 successfully, open VScode, File -> Preferences -> User Settings, enter "python.linting.flake8Enabled": true in the settings.json file
configure yapf
After installing yapf, press Alt+Shift+F in VScode to automatically format the code
- open command line
- Type "pip install yapf"
- After installing yapf successfully, open VScode, File->Preferences->User Settings, enter "python.formatting.provider": "yapf" in the settings.json file
a few tips
-
View the definition of a function or class
Ctrl + left mouse button Click the function name or class name to jump to the definition, and press F12 on the function name or class name to achieve the same function -
Change
the variable name Press F2 on the variable name to rename the variable -
Python breakpoint debugging
Click on the left side of the line number to set a breakpoint, and you can view the changes of variables in the debugging interface on the left -
Hiding the menu bar
is a personal habit. If you also feel that the menu bar is annoying, you can click View -> Switch Menu Bar to hide the menu bar. When you need the menu bar, press the Alt key to view it -
Set the shortcut key
file -> Preferences -> Keyboard shortcuts, copy the contents of the entire curly brackets of the shortcut keys you need to modify to the keybindings.json file on the right, and then modify the value of "key" to the shortcut key you need That's it. I only modified the shortcut keys for copying a line and deleting a line here.
finally
If you have anything to add or if you have any mistakes, please point out (。・`ω´・)
refer to
There are very detailed tutorials and demo gifs in pythonVSCode
Effect picture:
Install the python plugin
- Open VScode, Ctrl+p
- Enter "ext install python", the search time may be longer
- Select the plug-in with the highest download volume and click to install (according to the network situation, the installation time is uncertain, I installed it for a long time, I have already downloaded it here, so it shows uninstall)
At this point, VScode can edit the python code. After editing the code, press F5 to run it. The first run will let you choose the environment, just choose python.
By default, you need to press F5 again to run the program after pressing F5. If you want to press F5 to run immediately, you need to change "stopOnEntry": true in the launch.json file to "stopOnEntry": false.
Recommend a plugin, vscode-icons can make the resource manager on the left side of VScode display icons according to the file type
configure flake8
After installing flake8, when writing code, the editor will prompt where is the error, and the code format is not standardized.
- open command line
- Type "pip install flake8"
- After installing flake8 successfully, open VScode, File -> Preferences -> User Settings, enter "python.linting.flake8Enabled": true in the settings.json file
configure yapf
After installing yapf, press Alt+Shift+F in VScode to automatically format the code
- open command line
- Type "pip install yapf"
- After installing yapf successfully, open VScode, File->Preferences->User Settings, enter "python.formatting.provider": "yapf" in the settings.json file
a few tips
-
View the definition of a function or class
Ctrl + left mouse button Click the function name or class name to jump to the definition, and press F12 on the function name or class name to achieve the same function -
Change
the variable name Press F2 on the variable name to rename the variable -
Python breakpoint debugging
Click on the left side of the line number to set a breakpoint, and you can view the changes of variables in the debugging interface on the left -
Hiding the menu bar
is a personal habit. If you also feel that the menu bar is annoying, you can click View -> Switch Menu Bar to hide the menu bar. When you need the menu bar, press the Alt key to view it -
Set the shortcut key
file -> Preferences -> Keyboard shortcuts, copy the contents of the entire curly brackets of the shortcut keys you need to modify to the keybindings.json file on the right, and then modify the value of "key" to the shortcut key you need That's it. I only modified the shortcut keys for copying a line and deleting a line here.
finally
If you have anything to add or if you have any mistakes, please point out (。・`ω´・)
refer to
There are very detailed tutorials and demo gifs in pythonVSCode