Recommended Settings and Extensions in VS Code
VS Code is highly customizable and has a rich ecosystem of extensions that can extend VS Code’s functionality. In this section, we recommend several configurations and extensions that we have found provide the best user experience for data scientists using VS Code on Posit Workbench.
Recommended settings
We recommend configuring the following settings at the user level. To edit your user settings file, activate the Command Palette using Cmd + Shift + P on macOS or Ctrl + Shift + P on Windows and Linux, and then type “Preferences: Open Settings (JSON)”.
{
"[python]": {
"editor.rulers": [
80
],
"editor.tabSize": 4
},
"[r]": {
"editor.rulers": [
80
],
"editor.tabSize": 2
}
}
[python]
All values in this section apply only to .py
files. Enable a vertical ruler at 80 spaces and set tab size to 4 spaces to align with best practice per pep8.
[r]
All values in this section apply only to .r
files. Choose values that align with your style guide of choice. For example, enable a vertical ruler at 80 spaces and set tab size to 2 spaces to align with best practice per the tidyverse style guide.
jupyter.interactiveWindow.textEditor.executeSelection
This setting is now configured by default.
Send the selected code from a .py
file directly to an interactive jupyter window by pressing Shift + Enter.
Recommended extensions
We recommend installing the following extensions. To read more about installing extensions, please refer to the VS Code Extensions section.
Quarto
The Quarto extension provides language support for .qmd
files. Learn more about Quarto at https://quarto.org.
Shiny
This is an extension to help launch Shiny applications. Shiny is a package for Python and R that is designed to make it easy to build interactive web applications with the powerful data and scientific features of Python and R.
Publisher
Posit Publisher lets you deploy projects to Connect from VS Code.
Key concepts:
- Publisher is an extension that presents a UI within the VS Code sidebar.
- Deployment options are set via configuration files in
.posit/publish/
. - Records of where you have deployed are kept in
.posit/publish/deployments
.
See the Publisher Installation instructions for more information.
Python
The official Python extension from Microsoft provides rich language support for the Python Language. Features include:
- The ability to create, edit, and execute Jupyter Notebooks
- Code refactoring
- Code auto-completion
- Code formatting
- Debugging tools
- Unit testing tools
When using the Python extension on Posit Workbench, VS Code is not able to use the Pylance language server (source).
Pylance is licensed for use in Microsoft products and services only, so it cannot be used with Posit Workbench.
Pylance is an optional dependency.
Users can switch the Python Language Server Protocol (LSP) to the other bundled Language Server, Jedi. Activating Jedi will re-enable rich language support such as code completion, error reporting, type checking, and other useful Python support that otherwise would be missing as Pylance is non-functional.
Users can modify settings from the UI editor or edit settings.json
files directly. Please refer to the screenshots below to access the UI editor, search for Python: Language Server
, and set Jedi as the language server
The Python extension automatically also installs the Jupyter extension. If you are working in an offline environment and want to install the Python extension, you will need to install the Jupyter extension manually.
R
The R extension provides support for the R programming language. For the extension to work, you must install the languageserver
in R.
install.packages("languageserver")
Additional extensions
There are several additional extensions that may improve your VS Code user experience. These extensions are not included in this section because they are not tested against Workbench. These extensions can be review in the VS Code - Appendix