Install VS Code

Why VS Code?

VS Code (Visual Studio Code) is the editor you use for everything in this course: writing and running R, rendering Quarto documents, taking notes in your course workspace, and managing Git and GitHub. It is a professional, free, lightweight editor used by developers worldwide, and keeping all of your work in one editor means your code, your notes, and your reproducible report live together in a single workspace.

In this course VS Code is the standard environment. This guide installs it and sets up the extensions you need; pair it with Install R to run R inside it.


System requirements

  • Windows 10+, macOS 10.12+, or Linux (most distributions)
  • At least 200 MB of disk space
  • Runs comfortably on any computer that can run R

Step 1: Download VS Code

  1. Go to code.visualstudio.com.
  2. Click the large Download button.
  3. Pick your operating system:
    • Windows: “Windows (64-bit)”
    • macOS: choose Intel or Apple Silicon to match your chip
    • Linux: choose your distribution

Step 2: Install VS Code

Windows

  1. Run the downloaded .exe.
  2. Accept the agreement, keep the default location, click through, then Install and Finish.

macOS

  1. Open the .dmg and drag Visual Studio Code into Applications.
  2. Open it from Applications.

Linux (Ubuntu/Debian)

sudo apt update
sudo apt install code

Step 3: Learn the layout

When VS Code opens you’ll see:

  • Left sidebar: file explorer, search, source control, extensions
  • Editor (center): where you write code and prose
  • Bottom panel: the integrated terminal and problems
  • Top bar: File, Edit, View, Run menus

Step 4: Install the course extensions

Open the Extensions view (Ctrl/Cmd+Shift+X) and install these. If you cloned the course workspace, it will simply prompt you to install its recommended set.

1. R (REditorSupport), required

Search for R by REditorSupport and click Install. This is what lets you run R, get completions, and view data inside VS Code. Finish the wiring in Install R.

2. Quarto, required

Search for Quarto by Posit and click Install. This gives you the Render button, the preview pane, and highlighting for the .qmd documents you write for assignments and your final report.

WarningThis extension is not the Quarto program

The extension is a front end. It needs Quarto itself, a separate download, installed on your computer, and it does not install it for you. If you stop here the Render button will do nothing and quarto render will report that the command was not found.

Install the program: Install Quarto.

Optional extras

  • Markdown All in One adds a table of contents, shortcuts, and list editing for Markdown.
  • Python (by Microsoft), only if you branch into Python. It is not required for this course.

Step 5: Connect to GitHub

  1. Click the Accounts icon (bottom-left) or the Source Control icon (branch symbol).
  2. Click Sign in with GitHub and complete authentication in your browser.

Now you can clone repositories, view history, and commit and push without leaving VS Code. See Getting Started with GitHub.


Step 6: Open your first workspace

In VS Code you work in a folder, not a project file. The open folder is your working directory.

  1. File, Open Folder and choose a folder (for example, your cloned course workspace).
  2. Create a file called hello.R and type:
print("Hello, Communication Liaison!")
  1. Put your cursor on the line and press Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac). VS Code starts an R terminal and runs it.
  2. You should see [1] "Hello, Communication Liaison!" in the terminal.

Step 7: The integrated terminal

Press Ctrl+` (backtick, below Escape) or View, Terminal. From here you can run:

  • git status to check your repository
  • R to start an interactive R session
  • quarto render to build a document

Type exit to close it.


Step 8: Essential keyboard shortcuts

Action Windows/Linux Mac
Open folder Ctrl+K Ctrl+O Cmd+K Cmd+O
Save file Ctrl+S Cmd+S
Run R line Ctrl+Enter Cmd+Enter
Find text Ctrl+F Cmd+F
Open terminal Ctrl+| Ctrl+
Command Palette Ctrl+Shift+P Cmd+Shift+P
Markdown preview Ctrl+Shift+V Cmd+Shift+V
Add comment Ctrl+/ Cmd+/

Step 9: Clone a repository

  1. Open the Command Palette (Ctrl/Cmd+Shift+P) and run Git: Clone.
  2. Paste the repository URL and choose a folder.
  3. Click Open when prompted.

Your whole repository is now in VS Code, ready to edit, commit, and push.


Step 10: Settings and customization

  • Theme: File, Preferences, Theme, Color Theme (Dark+, Light+, or a community theme).
  • Font size: Settings, search “font size”.
  • Format on save: Settings, search “format on save”, and check the box.

Common issues and fixes

The R extension cannot find R

Install R first (Install R), then in Settings search r.rpath and point it at your R executable. Restart VS Code.

Extensions won’t install

Check your internet connection, then try installing from the Extension Marketplace website. As a last resort, reinstall VS Code.

Terminal says “git: command not found”

Install Git (see Getting Started with GitHub) and restart VS Code.

“Git: Clone” is not in the Command Palette

VS Code hides that command instead of greying it out, so when Git is not visible to VS Code the command is simply not on the list. Three causes, in the order worth checking.

1. VS Code was open while you installed Git. This is much the most common. VS Code reads your PATH once, at the moment it starts, so a program installed afterwards stays invisible to it. Quit VS Code completely and open it again. On a Mac use Cmd+Q, because closing the window leaves it running. Reload Window does not help, because the program keeps the PATH it started with.

2. Windows: Git was installed without being added to your PATH. The Git installer has a page about adjusting your PATH, and the right choice is the middle option, Git from the command line and also from 3rd-party software. If you picked Use Git from Git Bash only, VS Code cannot see it. Run the Git installer again and choose the middle option.

3. Mac: the developer tools prompt was cancelled. Open Terminal and run git --version. If a box offers to install the command line developer tools, click Install and let it finish, then quit and reopen VS Code.

To check what VS Code can actually see, open a terminal inside VS Code (Terminal, New Terminal) and run git --version. If that prints a version but the command is still missing after a full restart, point VS Code at Git yourself: open Settings, search git.path, and set it to the full path of the program. On Windows that is usually C:\Program Files\Git\bin\git.exe.

If you need to get on with it now, you do not have to wait for the palette. In a terminal inside VS Code, cd to where you want the folder and run git clone with the URL you copied from GitHub. That does exactly what the palette command does.

The installer says the drive or UNC share does not exist

This happens on Windows when VS Code was previously installed somewhere that is no longer there, most often an external drive that has since been unplugged or wiped. The installer remembers the old location and tries to reuse it, so it stops on a drive letter that no longer exists.

First, unplug the external drive if it is connected, so the installer cannot default back to it. Then:

  1. Find the folder VS Code should actually go in. Open PowerShell from the Start menu and run this, then copy the line it prints:

    "$env:LOCALAPPDATA\Programs\Microsoft VS Code"
  2. Download the User Installer for Windows from code.visualstudio.com and run it.

  3. On the Select Destination Location page, delete whatever is in the box and paste the path from step 1. Then continue through the installer normally.

If the box will not accept it, or the same message comes back, Windows is still holding a record of the old install. Look at what it thinks is there:

Get-ChildItem 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | ForEach-Object { Get-ItemProperty $_.PSPath -EA SilentlyContinue } | Where-Object { $_.DisplayName -like '*Visual Studio Code*' } | Select-Object DisplayName, InstallLocation

An InstallLocation on a drive other than C: is the problem. Clear that leftover record:

Get-ChildItem 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall' | Where-Object { (Get-ItemProperty $_.PSPath -EA SilentlyContinue).DisplayName -like '*Visual Studio Code*' } | Remove-Item -Recurse -Force

That removes only Windows’ note about the old install. It deletes no programs and none of your files. Run the installer again afterwards.

Verify: leave the external drive unplugged, then open VS Code from the Start menu. If it opens, the new copy is on your internal drive and does not depend on the external one.

Uninstalling first through Settings, Apps will not work here, because the uninstaller lived in the folder that was deleted along with everything else.

Your old settings and extensions are stored separately and are not affected by any of this, so they should reappear once VS Code opens.


Next steps

  1. Installed VS Code.
  2. Installed the R, Quarto, and GitLens extensions.
  3. Connected GitHub.
  4. Opened a workspace and ran R from the editor.
  5. Next: finish Install R, then set up your course workspace.

Resources

Questions? Press F1 for the Command Palette, check the docs, or come to office hours.