VSCode Usage¶
Description¶
Visual Studio Code (VS Code) is a text/code editor and a fully Integrated Development Environment (IDE) for various programming languages. It is actively developed by both Microsoft and the community because of it's open source nature.
Basic Navigation¶
- To create a new file, click on the top left of VSCode, Click File > New File... (or press Ctrl+Alt+Windows+n) and select the file type that you want.
- To open an existing file, click on the top left of VSCode, Click File > Open File... (or press Ctrl+o) and select the file type that you want.
- To switch between open tabs, Press Ctrl+Tab and select the open tabs that you want.
- To search for files, Press Ctrl+p to find all files with the matching pattern.
- To save the current file, Click File > Save (or press Ctrl+s).
- To run a command line command, Click on Terminal > New Terminal (or press Ctrl+Shift+`) to open the command line and type the command.
Editing¶
- To search for text in the current file, Press Ctrl+f to find all files with the matching pattern.
- To run the current file, click on Run > Run Without Debugging.
- To undo the latest change, Click Edit > Undo (or press Ctrl+z).
- To redo the latest undone change, Click Edit > Redo (or press Ctrl+y).
Extensions¶
You can install extensions to VS Code by clicking Extensions (or press Ctrl+Shift+X), searching for the extension that you want to install and clicking install.
For Python development¶
Make sure that the Python and Pylance extensions are installed. If they are not, click the Extensions button on left Menu, search for Python and/or Pylance and click Install. For Jupyter Notebook support, you can download the Jupyter extension (and optionally the Jupyter Keymap).
Creating virtual environments¶
- Click on Search > Show and Run Commands (or press Ctrl+Shift+p).
- Search for the command Python: Create Environment.
- Click Python: Create Environment and select the type of virtual environment that you want to create (Venv, Conda). (If you are sent a notification about setting a workspace, create or select your project folder).
- (Venv) Select the Python interpreter that you want to use for the virtual environment. If you want to use a specific version of python, you must have that version of Python installed (All Python Versions).
Installing PIP packages¶
- Click on Terminal > New Terminal (or press Ctrl+Shift+`) to open the command line.
- To install packages, run
pip install package package2
(or ex.pip install package==1.0.3
to install the version 1.0.3 of the package orpip install requirements.txt
to bulk install packages from a requirements.txt file)
Python Testing¶
- Open the file you want to test and click the Testing button on the left Menu.
- Select the testing framework that you want to use.
- Select the directory containing the tests.
- Select identifier for test files.
For a more information, see here.