Introduction to Visual Studio Code for Web Development

Jul 18, 2024

Introduction to Visual Studio Code for Web Development

Overview

  • Learn to set up and use Visual Studio Code (VS Code) for web development.
  • VS Code is a popular, free, open-source, cross-platform code editor.

Why VS Code?

  • Free and open-source
  • Cross-platform (Windows, Linux, macOS)
  • Extensive community support and many extensions
  • Fully customizable and lightweight

Installation

  • Download VS Code from code.visualstudio.com/download.
  • Select the appropriate version for your OS and install.
  • During installation, check all additional tasks to integrate VS Code fully into your OS.

Basic Interface Overview

  • Sidebar: Contains various tools and panels.
    • Explorer: View project files and directories.
    • Search: Find and replace within your project files.
    • Source Control: Git integration.
    • Run and Debug: (Not covered in detail)
    • Extensions: Add functionality via extensions.
  • Manage Cog: Access settings, themes, and shortcuts.
  • Command Palette: Access all commands (~ shortcut: Ctrl+Shift+P or F1).
  • Status Bar: Displays current branch, line number, language, etc.

Key Shortcuts

  • Command Palette: Ctrl+Shift+P or F1
  • Sidebar: Toggle with Ctrl+B
  • Explorer: Ctrl+Shift+E
  • Search: Ctrl+Shift+F
  • Source Control: Ctrl+Shift+G
  • Debug: Ctrl+Shift+D
  • Extensions: Ctrl+Shift+X
  • Open File: Ctrl+P
  • Keyboard Shortcuts Panel: Ctrl+K Ctrl+S
  • Settings: Ctrl+Comma

Initial Setup

  • Font Size: Change to personal preference (example: 18).
  • Tab Size: Change to personal preference (default is 4, example: 2).
  • Bracket Pair Colorization: Enable it.
  • Word Wrap: Turn on to prevent code from overflowing.
  • Themes: Access via Manage Cog > Themes or Ctrl+K Ctrl+T.
    • Popular themes: Night Owl, Cobalt 2, Shades of Purple, Coder Coder Dark, Code Stacker.
  • Icon Packs: Install additional icon packs (example: VS Code Icons, Fluent Icons).

Creating a Project Structure

  • Open a Project Folder:
    • Right-click folder > Open with VS Code.
    • Inside VS Code: File > Open Folder.
  • Adding Files and Folders:
    • Create new files and folders using sidebar or Add New File/Folder button.
    • Use / to create folder and file simultaneously (e.g., js/app.js).

Emmet & Intellisense

  • Emmet:
    • Use shorthand to speed up HTML/CSS coding.
    • Example: ! for basic HTML structure, ul>li*4 for a list with 4 items.
  • Intellisense:
    • Provides context-aware suggestions.
    • Available for many programming languages.

Extensions

  • Live Server: Auto-refresh for real-time code changes (~17M downloads).
  • Prettier: Code formatter for uniform code.
  • Auto Rename Tag: Automatically renames paired HTML tags.
  • Additional Extensions: Search and install from the Extensions panel.

Using the Terminal

  • Open terminal with Ctrl+Backtick or Terminal > New Terminal.
  • Set default terminal (Preferences > Select Default Profile).
  • Useful for git, npm, and other command-line tools.

Learning and Next Steps

  • Follow HTML, CSS, and JavaScript crash courses.
  • Explore additional VS Code resources and courses at vscodehero.com.

Conclusion

  • VS Code is a comprehensive and customizable tool for web development.
  • Invest time in learning shortcuts and features to maximize productivity.