Chapter 3 Installing Visual Studio Code

Visual Studio Code (VSCode) is a powerful, free code editor that works excellently with R, Quarto, and GitHub Copilot. Let’s get it installed!

What you’ll accomplish in this chapter:

  • ✅ Download and install VSCode
  • ✅ Install essential extensions for R and Quarto
  • ✅ Configure VSCode for this course
  • ✅ Test that everything works

3.1 Step 1: Download VSCode

3.1.1 For Windows Users

  1. Go to https://code.visualstudio.com
  2. Click the large “Download for Windows” button
  3. The download will start automatically (file: VSCodeUserSetup-x64-*.exe)

3.1.2 For macOS Users

  1. Go to https://code.visualstudio.com
  2. Click the large “Download for Mac” button
  3. The download will start (file: VSCode-darwin-universal.zip)

Apple Silicon (M1/M2/M3) vs Intel:

The universal download works for both! If you want a specific version:

  • Apple Silicon (M1/M2/M3): Choose “Apple Silicon”
  • Intel Macs: Choose “Intel Chip”

Not sure which you have? Click Apple menu () → About This Mac. If it says “Apple M1” or “M2” or “M3”, you have Apple Silicon.

3.1.3 For Linux Users

  1. Go to https://code.visualstudio.com/Download
  2. Choose your distribution:
    • .deb (Debian/Ubuntu)
    • .rpm (Fedora/Red Hat)
    • .tar.gz (Generic Linux)

3.2 Step 2: Install VSCode

3.2.1 Windows Installation

  1. Locate the downloaded file (usually in Downloads folder)
  2. Double-click VSCodeUserSetup-x64-*.exe
  3. Accept the license agreement
  4. Click “Next” through the installer
  5. Important: On the “Select Additional Tasks” screen, check these boxes:
    • ✅ Add “Open with Code” action to Windows Explorer file context menu
    • ✅ Add “Open with Code” action to Windows Explorer directory context menu
    • ✅ Add to PATH (requires shell restart)
  6. Click “Install”
  7. Wait for installation to complete (about 1-2 minutes)
  8. Click “Finish” and launch VSCode

Permission prompt:

Windows may ask “Do you want to allow this app to make changes to your device?” Click “Yes” to continue.

3.2.2 macOS Installation

  1. Locate the downloaded .zip file (usually in Downloads folder)

  2. Double-click to extract it → You’ll see Visual Studio Code.app

  3. Drag Visual Studio Code.app to your Applications folder

  4. Launch VSCode from Applications or Spotlight (⌘+Space, type “Visual Studio Code”)

“Visual Studio Code.app” can’t be opened:

macOS may block apps from unidentified developers. If you see this message:

  1. Go to System Settings → Privacy & Security
  2. Scroll down to find the message about VSCode
  3. Click “Open Anyway”
  4. Confirm by clicking “Open”

3.2.3 Linux Installation (Debian/Ubuntu)

Open Terminal and run:

# Download the .deb file first from https://code.visualstudio.com/Download
# Then install:
sudo dpkg -i ~/Downloads/code_*.deb

# Fix any dependency issues:
sudo apt-get install -f

For Fedora/RHEL:

# Install the .rpm file:
sudo rpm -i ~/Downloads/code-*.rpm

3.3 Step 3: First Launch and Welcome Screen

When you first open VSCode, you’ll see the Welcome screen:

Familiarize yourself with the interface:

  • Activity Bar (left side): Access different views (Explorer, Search, Extensions, etc.)
  • Side Bar: Shows content from the selected Activity Bar view
  • Editor: Where you write code (currently shows Welcome tab)
  • Status Bar (bottom): Shows info about your current file

3.4 Step 4: Install Essential Extensions

Extensions add superpowers to VSCode! Let’s install the extensions you need for this course.

3.4.1 4.1 Open the Extensions View

Click the Extensions icon in the Activity Bar (looks like four squares) or press:

  • Windows/Linux: Ctrl+Shift+X
  • macOS: ⌘+Shift+X

3.4.2 4.2 Install the R Extension

  1. In the search box, type: “R”
  2. Find “R” by REditorSupport (it will be the first result)
  3. Click “Install”

Extension publisher matters!

Make sure the extension is by REditorSupport (the official R extension). It should have a blue checkmark and millions of downloads.

3.4.3 4.3 Install the Quarto Extension

  1. Search for: “Quarto”
  2. Find “Quarto” by Quarto.org
  3. Click “Install”

3.4.4 4.4 Install GitHub Copilot Extension

  1. Search for: “GitHub Copilot”
  2. Find “GitHub Copilot” by GitHub
  3. Click “Install”

You’ll sign into Copilot later!

Don’t worry about signing in yet. We’ll set up Copilot in Chapter 6 after everything else is installed.

3.4.5 4.5 Install GitHub Copilot Chat Extension

  1. Search for: “GitHub Copilot Chat”
  2. Find “GitHub Copilot Chat” by GitHub
  3. Click “Install”

3.4.7 4.7 Install Additional Helpful Extensions

These are optional but recommended for a better coding experience:

Extension Purpose Search Term
Markdown All in One Better markdown editing “Markdown All in One” by Yu Zhang
Code Spell Checker Catch typos in comments “Code Spell Checker” by Street Side Software
indent-rainbow Visualize code indentation “indent-rainbow” by oderwat
Bracket Pair Colorizer Color-code matching brackets Built-in (enable in settings)

3.4.8 Summary: Extensions You Should Have

After this step, you should have these extensions installed:

3.5 Step 5: Configure VSCode Settings

Let’s adjust a few settings to optimize VSCode for this course.

3.5.1 5.1 Open Settings

  • Windows/Linux: Ctrl+, (Ctrl+Comma)
  • macOS: ⌘, (Cmd+Comma)

Or: Click File → Preferences → Settings (on Mac: Code → Settings → Settings)

3.6 Step 6: Test Your VSCode Setup

Let’s make sure everything is working!

3.6.1 6.1 Create a Test R Script

  1. Click File → New File (or Ctrl+N / ⌘+N)
  2. VSCode will ask “Select a language” → Type “R” and press Enter
  3. Type this simple R code:
# Test script for VSCode
print("Hello from VSCode!")

# Simple calculation
x <- 5
y <- 10
result <- x + y
print(paste("The sum is:", result))
  1. Save the file: File → Save As → Name it test.R

Syntax highlighting working?

If the R extension is working, you should see:

  • Comments (lines starting with #) in green or gray
  • Strings (“Hello from VSCode!”) in red or orange
  • Numbers (5, 10) in a different color
  • Keywords (<-, print) highlighted

If everything looks plain black text, the R extension may not be active. Try restarting VSCode.

3.6.2 6.2 Run the R Code (We’ll set up R in Chapter 4!)

Don’t worry if this doesn’t work yet!

We haven’t installed R itself yet (that’s in Chapter 4). For now, just confirm that:

  • ✅ VSCode opens and runs smoothly
  • ✅ You can create and save .R files
  • ✅ Syntax highlighting works
  • ✅ Extensions are installed

We’ll come back and test code execution after installing R!

3.7 Video Tutorial: Installing and Setting Up VSCode

Video Tutorial:

Watch directly on YouTube: VS Code Tutorial for Beginners

3.8 Summary Checklist

Before moving to the next chapter, make sure you have:

Troubleshooting:

VSCode won’t open: - Try restarting your computer - Check that you have administrator permissions - Re-download and reinstall

Extensions won’t install: - Check your internet connection - Restart VSCode and try again - Make sure you’re searching for the exact extension name

Still stuck? Reach out via email or office hours!


Next: Chapter 4: Installing RStudio and R