Configure VSCode for maximum productivity

## How do we configure VSCode?

VSCode has a built-in configuration setting that you can access using Ctrl/Cmd followed by a , (comma).

At the same time, VSCode is extensible using its Marketplace of extensions.

## What built-in options should I configure VSCode for maximum productivity?

### Autosave

Save some keystrokes by configuring VSCode to autosave your files after 10 ms. This is useful if your workflow doesn't involve running a live server that reloads code on every save.

### Format on save/paste

When you explicitly command VSCode to save your file, it can run code formatters (such as black) on the file being saved.

### Insert Final Newline

This option will insert a final newline to a plain text file. Makes viewing them in the terminal much easier.

### Trim trailing whitespace

This will clean out trailing whitespace. Again, makes viewing them in the terminal a bit easier.

## What VSCode extensions help with productivity?

### Python + Pylance

The official Python extension for VSCode contains a ton of goodies that are configurable in the settings. It can help you load conda environments in the shell directly, automatically lint source code that is open, debug a program that has to be executed, automatic importing of resolvable functions and modules, and many, many more goodies for Python developers and data scientists.

In fact, you can write a .py file and execute it interactively as if it were a Jupyter notebook, without the overhead of the Jupyter front-end interface. Steven Mortimer even has an R-bloggers post on how to configure VSCode to behave like RStudio for Python, for those who prefer the RStudio interface!

With the Python extension being powerful as it is, the Pylance extension will supercharge it even more. Using an extremely performant code analyzer, it will highlight nearly all problems it detects within a source .py file within a few hundred milliseconds (maximum) of the file being saved. When I have had to do tool development as part of my data science work, Pylance has been essential for my productivity.

### Peacock

One good practice we have written about here is to Follow the rule of one-to-one in managing your projects. When one project has one directory, that directory acts as a "workspace", which in turn gets opened in one VSCode window. If you have 3-4 windows open, then figuring out which one corresponds to which project can take a few seconds.

### VSCode Remote

This extension gives you superpowers. It will enable you to edit code on a remote server while still having all of the goodies of a locally-running VSCode session. Leverage this extension to help you develop on a powerful remote machine without ever leaving your local editor.

### indent-rainbow

This extension highlights indentation in different colours, making it easier to read Python (and other indentation-friendly languages') source files.

### Rainbow CSV

Rainbow CSV highlights the columns in a CSV file when you open it up in VSCode, making it easier to view your data. This one was suggested by one of my book reviewers Simon Eng.

### markdownlint

This extension checks your Markdown files for formatting issues, such as headers containing punctuations, or missing line breaks after a header. These are based on the Node.js markdownlint package by David Anson.

### Markdown Table Prettifier

Also suggested by Simon, Markdown Table Prettifier helps you format your Markdown tables such that they are easily readable in plain text mode.

### Polacode

Polacode is "polaroid for code", giving you the ability to create "screenshots" of your code to share with others. If you've ever used carbon.now.sh, you'll enjoy this one.