Sea of Tranquility    About    Archive    Feed

Setting up VS Code

Visual Studio Code or simply VS Code is an Integrated Development Environment (IDE) built by Microsoft. It is a very popular free and opensource IDE among software developers.

After reading this article, you will be able to

  1. Download and install VS Code

  2. Get it ready for Python development

  3. Change VS Code themes

  4. Change settings (both User and Workspace) according to your needs, and

  5. Add a vertical ruler to the editor.

The installation instructions are applicable only to Unix based systems (i.e. Linux and Mac OS).

Get VS Code on your machine

sudo dpkg -i <filename>
sudo apt install -f

VS Code you have now is nothing more than a very well designed text editor. While this is certainly a good feature, you can make it better by customising it according to you needs. Since you want to code in Python, let’s first install the Python extension for VS Code.

Get VS Code ready for Python

In this step, we install a Python extension and select a Python interpretor to compile the code.

Install the Python extension

Open VS Code and hit Ctrl + Shift + X. This opens the VS Code Extension Market Place.

Type Python in the search field. You will get many results, but click on the one with Microsoft’s name. Click Install in the new window that opens.

Select the Python interpretor

We generally have more than one version of Python interpreter installed. Therefore, we need to tell VS Code which version to use to process the code. This is how we do it.

Change how VS Code looks

With the basic set up ready, we can now change the default settings according to our taste. Let’s start with the overall theme first.

Change User and Workspace Settings

VS Code can be configured at two different levels: User and Workspace. User Settings affect behaviour of VS Code globally. Workspace Settings are applicable only to a particular project. However, Workspace Settings override User Settings.

Let’s look at a simple example to understand this better. Suppose you are comfortable with a font size of 20. To make this your default font size, you go to User Settings and set font size to 20. Now, suppose that, you are working on a project that will be reviewed regularly by someone who prefers a bigger font, say 24. Instead of increasing the font size every time your reviewer comes, you can set 24 as the default font size for that particular project. You do this by changing the font size in Workspace Settings. Since, Workspace Settings override the User Settings, your project file be displayed with a font size of 24 even though the default font size is 20.

Now let’s see how we can change User and Workspace Settings.

Both User and Workspace Settings are saved in two different files. Both the files have the same name settings.json but are created at different locations. Table below summarises the two types of settings.

User and Workspace Settings

Adding vertical rulers

It’s a good practice to have not more than 80 characters in a line of code. But, how do we know whether we are well within this limit? One can look at the column number, but that’s not practical. Instead, we can add a vertical ruler at the 80th column. This is how you add it:

That’s it! Now you have your VS Code up and running, and you also know how to change things if need be.