10 VSCode Productivity Hacks for Data Scientists
10x your productivity with these VSCode extensions
Introduction
Visual Studio Code (VSCode) is one of the most popular Integrated Development Environment amongst data science professionals. It supports a large number of programming languages, comes with terminal integration, built-in debugger, intuitive keyboard shortcuts, Jupyter Notebook support and customizable layout. If you can’t find built-in functionalities that meet your needs, head over to VSCode extension marketplace. It has an extensive selection of more than 30,000 extensions, one of which might be what you are looking for. In this article we handpicked 10 VSCode extensions that will help increase your productivity as a Data Scientist.
1. AutoDocString
Docstrings also known as documentation strings are string literals which describes a python class, function or method. Docstrings serve as a guide for developers who are trying to use the class, function or method that you have developed.
AutoDocString helps to generate pre-filled docstrings based on the defined variable names, return values, type hints and raised error.
Check out this tutorial on how to use AutoDocString for your data science projects.
2. Better Comments
Interweaving comments in your code provide human readable descriptions which makes maintenance and debugging easier. We often take important notes in the comments just to miss out on them while scrolling through the endless pages of code.
Better Comments helps to create more human-friendly comments in the code by enabling categorization of comments into highlights, alerts, questions and TODOs. Better Comments colour code the different category of comments making it easier to identify.
3. TODO MD
TODO MD is an advanced task list extension in VSCode to help you manage your to-dos in the markdown format. TODO MD allows annotation of tasks based on various attributes such as colour code, project name, context, tags, due dates etc. This simplifies the process of organising and searching for tasks. Let’s create a new markdown file in VSCode titled todo.md
.
- Prioritize the task list using uppercase alphabets in round brackets e.g.
(A)
,(B)
,(C)
- Annotate the tasks with project name using
+
symbol followed by the name of the project - Annotate the tasks with context using
@
symbol followed by the name of the context - Tag a task using
#
symbols followed by the tag name e.g. #HighImportance, #LowImportance - Assign due date to task using
{due: YYYY-MM-DD}
- Mark a completed task with completion date using
{cm: YYYY-MM-DD}
TODO MD panel helps to group your tasks based on various annotations and even has an alert icon beside tasks that are overdue.
4. IntelliCode
Code completion, also known as code prompt or autocomplete are tools that suggest the names of functions, methods, classes or keywords. Having code completion tools within your integrated development environment can greatly increase your productivity as it reduces manual entry of keywords or searching through documentations for classes, methods and functions.
IntelliSense is a common code completion aid used in VSCode. Below image shows Pylance’s IntelliSense in action. Notice that the recommended code is displayed in alphabetical order and we have to cycle through these recommendations to find the method which we intend to use.
IntelliCode is an intelligent code completion extension which recommends code which you are most likely going to use. IntelliCode places codes that are most likely used at the top of the recommended list, marked by a star symbol. This helps save us time from cycling through all the possible code in alphabetical order.
5. Python Indent
In Python, indentations are spaces found at the beginning of a line of code which helps to indicate a block of code and improve code readability. Python Indent is a VSCode extension which helps to correct VSCode’s default indentation. Below are examples without and with python-indent extension enabled.
Proper indentation makes the code more human readable.
6. Indent-Rainbow
Indentations are often hard to read especially in codes with nested indentations. Indent-Rainbow helps to make these indentations more human readable by colour coding the indentations.
7. Code Spell Checker
How often did you make a silly spelling error in your docstring or comments only to be corrected by a fellow co-worker later through a pull request? Avoid these mistakes using Code Spell Checker. Code Spell Check helps to perform spell check and correct word suggestions for code, comments and docstrings. Let’s take a look at an example.
8. Markdown Preview Enhanced
Reading or writing markdown in its raw format can be tedious and confusing especially for beginners. Markdown Preview Enhanced is a markdown previewer which displays edits to your .md
files in real time allowing you to edit your markdown files quickly.
9. AREPL for Python
Debug your python code in real time with AREPL for Python.
An REPL (Read-Eval-Print-Loop) is an interactive environment where user’s input into the computer are read, evaluated and the results are returned to the users. AREPL stands for Automated REPL [1], it is a scratchpad in which debugging, running, and writing your code can all be done at the same time. Whenever you stop typing your code is evaluated and the output is shown. But not just the output — your local variables are saved for inspection as well. Update the code, and the values seamlessly change.
10. Carbon
Carbon-now-sh extension allows you to create beautiful images of your source code using carbon.now.sh through VSCode.
- Highlight the code you wish to share
- Either use the shortcut key
Alt+Cmd+A
or (Alt+Windows+A
on Windows) or Open the Command Palete (Cmd+Shift+P
orCtrl+Shift+P
on Windows), and type Carbon. You will be redirected to carbon.now.sh with your selected code populating the text box. - Make adjustments to your image
- Export image
Conclusion
In this article we shared 10 VSCode extensions that are useful for improving productivity of data scientists. These extensions broadly cover areas in documentation, code formatting and debugging. I hope this is helpful. Feel free to share your favourite VSCode extension in the comments below!
Join Medium to read more articles like this.
References
[1] Presentation: AREPL: real-time evaluation of python | PyCon 2018 in Cleveland, Ohio