Skip to main content

VS Code Setup Best Practices

A comprehensive guide for maximizing VS Code in Angular development. Covers recommended extensions, workspace settings, debug configuration, and team-wide settings sharing.

1. Essential Extensions​

Angular Official​

ExtensionIDFeatures
Angular Language ServiceAngular.ng-templateTemplate autocomplete, type checking, error detection, Go to Definition
Angular Schematicscyrilletuzi.angular-schematicsGUI for Angular CLI commands (generate components from right-click menu, etc.)

Nx​

ExtensionIDFeatures
Nx Consolenrwl.angular-consoleGUI wrapper for Nx/Angular CLI, project graph display, generator execution

Code Quality​

ExtensionIDFeatures
ESLintdbaeumer.vscode-eslintReal-time lint display and auto-fix
Prettieresbenp.prettier-vscodeCode formatter
EditorConfigEditorConfig.EditorConfigUnify basic editor settings across team (indentation, line endings, etc.)

Productivity​

ExtensionIDFeatures
Angular Snippetsjohnpapa.Angular2Angular code snippet collection
Auto Importsteoates.autoimportAutomatic imports for used types and modules
Move TSstringham.move-tsAuto-update import paths when moving files
Path Intellisensechristian-kohler.path-intellisenseFile path autocomplete

Testing​

ExtensionFeatures
Jest Runner / Karma Test AdapterIndividual test execution and debugging
Test Explorer UIVisual test results in tree view

Git​

ExtensionIDFeatures
GitLenseamodio.gitlensGit history, blame, per-line change author, diff comparison
Git Graphmhutchie.git-graphVisual branch structure graph

Styling​

ExtensionIDFeatures
SCSS IntelliSensemrmlnc.vscode-scssSCSS variable and mixin completion
Tailwind CSS IntelliSensebradlc.vscode-tailwindcssTailwind class completion (when using Tailwind CSS)

Documentation​

ExtensionFeatures
Document ThisAuto-generate JSDoc/TSDoc (/** + Enter)
Todo TreeList all TODO/FIXME comments

RxJS​

ExtensionFeatures
RxJS ExplorerVisualize RxJS operator marble diagrams (for learning and debugging)

3. Team Sharing with extensions.json​

Creating .vscode/extensions.json and committing it to the repository automatically suggests recommended extensions when team members open the project.

.vscode/extensions.json
{
"recommendations": [
"Angular.ng-template",
"nrwl.angular-console",
"dbaeumer.vscode-eslint",
"esbenp.prettier-vscode",
"EditorConfig.EditorConfig",
"johnpapa.Angular2",
"christian-kohler.path-intellisense",
"eamodio.gitlens"
],
"unwantedRecommendations": [
"ms-vscode.vscode-typescript-tslint-plugin"
]
}
PropertyDescription
recommendationsList of recommended extension IDs for the project
unwantedRecommendationsUnrecommended extensions (e.g., deprecated lint plugins)

4. Workspace Settings (settings.json)​

Including .vscode/settings.json in your repository shares unified editor settings across the team.

.vscode/settings.json
{
// Formatter settings
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,

// Code actions on save
"editor.codeActionsOnSave": {
"source.fixAll.eslint": "explicit",
"source.organizeImports": "explicit"
},

// TypeScript settings
"typescript.preferences.importModuleSpecifier": "relative",
"typescript.tsdk": "node_modules/typescript/lib",

// Angular Language Service
"angular.enable.strictMode": true,

// Hidden files
"files.exclude": {
"**/.git": true,
"**/node_modules": true,
"**/dist": true,
"**/.angular": true
},

// Search exclusions
"search.exclude": {
"**/node_modules": true,
"**/dist": true,
"**/.angular": true,
"**/coverage": true
}
}

Settings Explained​

SettingDescription
editor.formatOnSaveFormat with Prettier on file save
source.fixAll.eslintRun ESLint auto-fix on save
source.organizeImportsOrganize import statements on save
typescript.preferences.importModuleSpecifierrelative prioritizes relative path imports
files.excludeHide unnecessary directories from explorer
search.excludeExclude directories from search results

5. Debug Configuration (launch.json)​

Chrome Debugging​

.vscode/launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "ng serve (Chrome)",
"type": "chrome",
"request": "launch",
"preLaunchTask": "ng serve",
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}",
"sourceMapPathOverrides": {
"webpack:/*": "${webRoot}/*"
}
},
{
"name": "ng serve (Attach to existing Chrome)",
"type": "chrome",
"request": "attach",
"port": 9222,
"url": "http://localhost:4200",
"webRoot": "${workspaceFolder}"
}
]
}

Debugging Tips​

  • Ensure TypeScript source maps (sourceMap: true) are enabled in tsconfig.json
  • Breakpoints can be set in components (.ts), services, interceptors, etc.
  • Breakpoints cannot be set directly in templates (.html) — place breakpoints in component class methods instead

Test Debugging​

.vscode/launch.json (additional config)
{
"name": "Debug Tests (Jest)",
"type": "node",
"request": "launch",
"program": "${workspaceFolder}/node_modules/jest/bin/jest",
"args": [
"--runInBand",
"--config",
"jest.config.ts"
],
"console": "integratedTerminal"
}

SSR Debugging​

.vscode/launch.json (SSR config)
{
"name": "Debug SSR (Node.js)",
"type": "node",
"request": "attach",
"port": 9229,
"restart": true,
"localRoot": "${workspaceFolder}",
"remoteRoot": "."
}

Start the Node.js process with the --inspect flag during SSR execution, then attach with this configuration.

6. Development Tasks with tasks.json​

.vscode/tasks.json
{
"version": "2.0.0",
"tasks": [
{
"label": "ng serve",
"type": "shell",
"command": "npx ng serve",
"isBackground": true,
"problemMatcher": {
"owner": "typescript",
"pattern": {
"regexp": "\\((\\d+),(\\d+)\\)",
"line": 1,
"column": 2
},
"background": {
"activeOnStart": true,
"beginsPattern": "Compiling",
"endsPattern": "Compiled successfully"
}
},
"group": {
"kind": "build",
"isDefault": true
}
},
{
"label": "ng build",
"type": "shell",
"command": "npx ng build",
"group": "build",
"problemMatcher": ["$tsc"]
},
{
"label": "ng test",
"type": "shell",
"command": "npx ng test --watch=false",
"group": "test",
"problemMatcher": []
},
{
"label": "ng lint",
"type": "shell",
"command": "npx ng lint",
"group": "none",
"problemMatcher": ["$eslint-stylish"]
}
]
}

Key Points​

ItemDescription
isBackgroundSet for watch-mode tasks like ng serve
problemMatcherDisplay compile errors in real-time in VS Code's "Problems" panel
group.kind: "build"Execute instantly with Ctrl+Shift+B as the build task

For Nx projects, simply replace npx ng with npx nx for the same functionality.

7. Custom Snippets​

Creating snippet files under .vscode/ provides project-specific code templates.

.vscode/angular.code-snippets
{
"Angular Component": {
"prefix": "ng-component",
"scope": "typescript",
"body": [
"import { Component } from '@angular/core';",
"",
"@Component({",
" selector: 'app-${1:name}',",
" standalone: true,",
" imports: [${2:}],",
" templateUrl: './${1:name}.component.html',",
" styleUrl: './${1:name}.component.scss'",
"})",
"export class ${3:Name}Component {",
" $0",
"}"
],
"description": "Angular standalone component"
},
"Angular Service": {
"prefix": "ng-service",
"scope": "typescript",
"body": [
"import { Injectable } from '@angular/core';",
"",
"@Injectable({",
" providedIn: 'root'",
"})",
"export class ${1:Name}Service {",
" $0",
"}"
],
"description": "Angular injectable service"
},
"Angular Test (Component)": {
"prefix": "ng-test-component",
"scope": "typescript",
"body": [
"import { ComponentFixture, TestBed } from '@angular/core/testing';",
"import { ${1:Name}Component } from './${2:name}.component';",
"",
"describe('${1:Name}Component', () => {",
" let component: ${1:Name}Component;",
" let fixture: ComponentFixture<${1:Name}Component>;",
"",
" beforeEach(async () => {",
" await TestBed.configureTestingModule({",
" imports: [${1:Name}Component]",
" }).compileComponents();",
"",
" fixture = TestBed.createComponent(${1:Name}Component);",
" component = fixture.componentInstance;",
" fixture.detectChanges();",
" });",
"",
" it('should create', () => {",
" expect(component).toBeTruthy();",
" });",
" $0",
"});"
],
"description": "Angular component test scaffold"
},
"RxJS switchMap Pattern": {
"prefix": "rx-switchmap",
"scope": "typescript",
"body": [
"this.${1:source$}.pipe(",
" switchMap(${2:value} => this.${3:service}.${4:method}(${2:value})),",
" takeUntilDestroyed(this.destroyRef)",
").subscribe(${5:result} => {",
" $0",
"});"
],
"description": "RxJS switchMap with takeUntilDestroyed"
}
}

8. Angular Language Service Tips​

Angular Language Service is the most important extension for Angular development.

Key Features​

FeatureDescription
Template completionAutocomplete component properties, methods, and pipes in templates
Template type checkingReal-time type error display when strictTemplates is enabled
Go to DefinitionJump from template to component class properties and methods
Find ReferencesCross-reference search between templates and component classes
Rename (F2)Synchronously rename properties in templates and classes
Quick FixesAuto-add missing imports, auto-generate undefined properties

Enabling strictTemplates​

tsconfig.json
{
"angularCompilerOptions": {
"strictTemplates": true,
"strictInjectionParameters": true,
"strictInputAccessModifiers": true
}
}

Enabling strictTemplates makes template type checking stricter, helping catch bugs early.

9. Nx Console Deep Dive​

Installing Nx Console adds a dedicated panel to VS Code's sidebar.

Key Features​

FeatureDescription
Generator GUIFill in options via forms to generate components, services, and libraries
Project GraphDisplay interactive dependency graphs within VS Code
Task ExecutionRun build / serve / test / lint with one click
affected DisplayVisually confirm projects affected by current changes
Target ExecutionSelect and run targets from a tree view
Nx Cloud StatusCheck CI/CD execution status and cache hit rates
tip

The Nx Console generator GUI displays all available options as form fields, so you don't need to memorize CLI options.

10. Multi-Root Workspaces​

.code-workspace Files​

For large projects like Nx monorepos, you can leverage VS Code's multi-root workspaces.

my-project.code-workspace
{
"folders": [
{
"name": "Shell App",
"path": "apps/shell"
},
{
"name": "Shared UI",
"path": "libs/ui"
},
{
"name": "Workspace Root",
"path": "."
}
],
"settings": {
"files.exclude": {
"**/node_modules": true,
"**/dist": true
}
}
}

Tips​

  • Different settings can be applied per folder (launch.json, tasks.json separation)
  • Focus on only relevant projects within a large monorepo
  • Prepare workspace files tailored to each team member's area of responsibility

11. Keyboard Shortcut Optimization​

Frequently Used Shortcuts for Angular Development​

ShortcutFunction
Ctrl+.Quick Fix / Code Actions (add imports, etc.)
F12Go to Definition (navigate between template and component)
Shift+F12Find All References (including templates)
F2Rename (synchronized between template and class)
Ctrl+Shift+P → AngularExecute Angular-related commands
Ctrl+Shift+BExecute build task
Ctrl+`Toggle terminal
Ctrl+Shift+MShow Problems panel (view compile errors)
Ctrl+PQuick file open
Ctrl+Shift+ONavigate symbols within file

Custom Keybindings​

You can add convenient keybindings for Angular development in keybindings.json.

keybindings.json
[
{
"key": "ctrl+shift+g",
"command": "workbench.action.tasks.runTask",
"args": "ng serve"
}
]

12. Performance Optimization​

Strategies for improving VS Code performance in large-scale projects.

files.watcherExclude Configuration​

Exclude unnecessary directories from file watching to reduce CPU and memory usage.

.vscode/settings.json
{
"files.watcherExclude": {
"**/node_modules/**": true,
"**/dist/**": true,
"**/.angular/**": true,
"**/coverage/**": true,
"**/.nx/**": true
}
}

TypeScript Memory Limit Adjustment​

.vscode/settings.json
{
"typescript.tsserver.maxTsServerMemory": 4096
}

Disable Unnecessary Extensions​

  • You can disable unnecessary extensions on a per-workspace basis
  • Extensions for other frameworks (React/Vue) that aren't needed in Angular projects can improve performance when disabled

Angular Language Service Optimization​

.vscode/settings.json
{
"angular.log": "off",
"angular.forceStrictTemplates": true
}
Summary

By committing all VS Code configuration files (extensions.json, settings.json, launch.json, tasks.json) to the repository, you can build a unified development environment across the entire team. This also greatly streamlines onboarding for new members.