Recently in the study of Python, has been using notepad++ as an editor, accidentally found that the Vscode is attracted by its beauty value. After using it to find that it starts fast, plug-in rich, downloaded after installation almost without the configuration can be used directly, but also support markdown. Of course, the main thing is good-looking: p
:
Vscode
Installing the Python plugin
- Open Vscode,ctrl+p
- Enter "ext install python", the search time may be longer
- Select the most downloaded plugin click Install (according to the network situation, the installation time is not sure, I installed a long time, my side has been downloaded so display uninstall)
To this side vscode can edit the Python code, edit the code by F5 to run. The first run will allow you to choose the environment and Python.
The default press F5 after the need to press the F5 program to run, if you want to press F5 run immediately need to Launch.json file "Stoponentry": true, Change to "Stoponentry": false.
Introduce a plugin,vscode-icons can make Vscode to the left of the explorer based on the file type display icon
Configure Flake8
When you write code after installing Flake8, the editor will prompt you for errors, and the code format will prompt
- Open command Line
- Enter "Pip Install Flake8"
- After the installation of Flake8 is successful, open Vscode, file, preferences, user settings, enter "Python.linting.flake8Enabled" in the Settings.json file: True
Configure YAPF
Automatically format code by pressing ALT+SHIFT+F in Vscode after installing YAPF
- Open command Line
- Enter "Pip Install YAPF"
- After the installation of YAPF is successful, open Vscode, file, preferences, user settings, enter "Python.formatting.provider" in the Settings.json file: "Yapf"
A few tips
View the definition of a function or class
CTRL + left mouse click on the function name or class name to jump to the definition, the function name or the class name by pressing F12 can also achieve the same function
Change variable name
Rename a variable by pressing F2 on the variable name
Python breakpoint debugging
Click on the left side of the line number to set breakpoints, and on the left side of the debug screen you can see the variable changes
Hide the menu bar
This is a personal habit, if you also feel that the menu bar is very annoying, you can click on the view---toggle menu bar, can hide the menu bar. Press the ALT key when you need the menu bar to view
Set shortcut keys
File, preferences, keyboard shortcuts, copy the contents of the entire curly brace of the desired modifier shortcut to the right Keybindings.json file, and then modify the value of "key" to the shortcut you need. I only modified the shortcut keys for copying one row and deleting a row.
At last
What needs to be supplemented or where there is a mistake to welcome everyone to point out (?? ' ω′?
Reference
Python on Visual Studio Code
Pythonvscode
There are very detailed tutorials and demo gifs in this
Http://www.cnblogs.com/bloglkl/p/5797805.html
Write Python's correct posture with Vscode