Skip to content
Tutorials Center
My learning

Topics

Lesson 40 of 40 ยท Projects and Practice

Practice, Troubleshooting and Cheat Sheet

Practice VS Code with hands-on exercises, fix slow startup and misbehaving extensions with a bisect method, and keep a cheat sheet of the shortcuts and commands you need.

You have now met the extension system, the terminal, tasks, Git, remote development and many ways to customize the editor. This final lesson is for practice. It offers exercises you can do in a few minutes each, a method for finding the cause of problems and a cheat sheet to keep nearby.

The runnable stand-ins are small JavaScript programs: a startup-time budget calculator and an extension "bisect" simulation. They teach the technique; the real data comes from VS Code's own tools.

Hands-on exercises

Do these in a scratch folder. Each should take under ten minutes, and each uses something from this chapter.

  1. Extension audit. Open the Extensions view and filter with @installed. For each extension write one sentence on why you use it. Uninstall or disable what you cannot justify. See installing and managing extensions.
  2. Format on save. Create messy.js with inconsistent spacing. Install a formatter, set it as the default for JavaScript and turn on editor.formatOnSave. Prove it works. Then try formatOnSaveMode: "modifications" and see the difference on a file that was already messy.
  3. Two terminals, two jobs. Open a terminal that runs node --watch on a script and a second one for Git. Rename both. Kill one and restart it from the profile dropdown. See the integrated terminal.
  4. A custom profile. Add a terminal profile with its own color, set it as default, and confirm the tab color. See terminal profiles.
  5. A task with an input. Write a task that echoes a value chosen with a pickString input. See tasks.json.
  6. A problem matcher. Write a script that prints file:line:col: error: message lines and a matcher that fills the Problems panel. Click a problem to open the file. See problem matchers.
  7. Stage by lines. Change three separate places in one file; stage only the first and commit; then commit the rest separately. See source control basics.
  8. Create and resolve a conflict. Make two branches that edit the same line, merge them and resolve in the merge editor. See diffs and merge conflicts.
  9. A chord shortcut. Bind ctrl+k ctrl+t to toggle the terminal... then check for a conflict in the Keyboard Shortcuts editor. See keybindings.
  10. A snippet with a mirrored tab stop. Create a trycatch snippet whose variable name appears twice. See snippets.
  11. Profile swap. Create a profile with no extensions and use it to test whether a problem is caused by an extension. See custom themes and profiles.
  12. Dev container. If you have Docker, add a Node dev container, reopen in it and run node --version. See dev containers.

Troubleshooting method

When something behaves strangely, resist the urge to change five settings at once. Follow this order:

  1. Reload the window: Command Palette > Developer: Reload Window. This fixes many stuck states.
  2. Read the output: View > Output has a channel per extension and for Git, tasks and the language server.
  3. Open the logs: Developer: Open Logs Folder or Help > Toggle Developer Tools shows console errors from the editor itself.
  4. Try without extensions: run code --disable-extensions from a terminal. If the problem vanishes, an extension is the cause.
  5. Bisect extensions: the command Help: Start Extension Bisect disables half of your extensions, asks whether the problem persists, and repeats until it finds the culprit.
  6. Try a clean profile: create a new empty profile; if all is well there, your settings or extensions are the cause.
  7. Check workspace settings: a .vscode/settings.json may override what you expect. The Settings editor shows the Workspace tab and a gear menu to copy the setting ID.
  8. Reset one thing: Preferences: Open Settings (JSON), remove the suspicious key. Keep a backup first.

Common problems and fixes

Symptom Likely cause and fix
Slow startup Many extensions. Use Developer: Startup Performance and Show Running Extensions to find slow activations
High CPU in a big repository File watcher or search over node_modules. Add files.watcherExclude and search.exclude
IntelliSense wrong or missing Wrong interpreter or SDK, or server crashed. Select the right one and restart the language server
Format on save does nothing No default formatter set for that language
code command not found Run Shell Command: Install 'code' command in PATH (macOS) or reinstall with the PATH option (Windows)
Terminal cannot find a tool VS Code inherited an old PATH. Quit all windows and restart
Git not detected Install Git or set git.path
Remote connection fails Check the SSH command in a normal terminal first and read the Remote - SSH output channel
Settings seem ignored A stronger layer overrides them (workspace over user, language block over general)
Debug breakpoint is grey The code that runs differs from the source (source maps, wrong working directory or build output)

Reduce load in large projects

JSON
{
  "files.watcherExclude": {
    "**/node_modules/**": true,
    "**/.git/objects/**": true,
    "**/dist/**": true
  },
  "search.exclude": { "**/node_modules": true, "**/dist": true },
  "files.exclude": { "**/.git": true }
}

The cheat sheet

I want to... Windows / Linux macOS
Command Palette Ctrl+Shift+P Cmd+Shift+P
Quick Open file Ctrl+P Cmd+P
Settings Ctrl+, Cmd+,
Keyboard Shortcuts Ctrl+K Ctrl+S Cmd+K Cmd+S
Toggle terminal Ctrl+` Ctrl+`
New terminal Ctrl+Shift+` Ctrl+Shift+`
Run build task Ctrl+Shift+B Cmd+Shift+B
Extensions view Ctrl+Shift+X Cmd+Shift+X
Source Control view Ctrl+Shift+G Ctrl+Shift+G
Search in files Ctrl+Shift+F Cmd+Shift+F
Go to definition F12 F12
Rename symbol F2 F2
Add next match Ctrl+D Cmd+D
Quick fix Ctrl+. Cmd+.
Format document Shift+Alt+F Shift+Option+F
Start debugging F5 F5
Toggle sidebar Ctrl+B Cmd+B
Zen mode Ctrl+K Z Cmd+K Z

Runnable stand-ins

JS Stand-in: find slow extensions

Press Run (or Ctrl + Enter) to see the console output here.

No output.

JS Stand-in: extension bisect

Press Run (or Ctrl + Enter) to see the console output here.

No output.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does Help: Start Extension Bisect do?

    It is a binary search over your enabled extensions, so a handful of rounds finds the culprit.
  2. 2. Which command-line flag starts VS Code without extensions?

    code --disable-extensions starts without any extensions, which helps tell whether one causes a problem.
  3. 3. A tool you just installed is not found by the integrated terminal. What is the usual fix?

    The terminal inherits the environment of the process that started VS Code, which may be stale.
  4. 4. How can you cut CPU use from file watching in a big project?

    Excluding folders such as node_modules from the file watcher reduces work.

Summary

  • Practice by doing small exercises that combine extensions, terminals, tasks, Git and customization.
  • Troubleshoot in a fixed order: reload, read output, disable extensions, bisect, clean profile.
  • Check the layered settings before assuming a setting is broken.
  • Keep a cheat sheet of the commands and shortcuts you use most.
  • Revisit the Visual Studio Code track to refresh any chapter.

Next: Back to the Visual Studio Code tutorial