Tutorial: Get started with Visual Studio Code
AI agents: See llms.txt for documentation discovery and navigation. Documentation articles are also available as Markdown by appending .md to the article URL. Join VS Code at Microsoft Ignite or catch the sessions online. A year of VS Code, wrapped. Explore the highlights. Tutorial: Get started with Visual Studio Code View as Markdown Ask in VS Code Ask in VS Code Insiders In this tutorial, you create a small recipe app while learning the key features of Visual Studio Code.
You work with files and the user interface, preview and debug the app, customize settings, explore optional extensions, and save your work with Git. The tutorial uses plain HTML, CSS, and JavaScript, with no additional extensions, build tools, runtime, AI account, or coding assistant required. Tip If you prefer a video introduction to Visual Studio Code, watch the Getting Started video on our YouTube channel. Prerequisites Download and install Visual Studio Code on your computer .
For the source control exercise, complete the Git prerequisites . These prerequisites include installing Git and configuring your Git author name and email address. You can complete the earlier sections without Git. Open a folder in VS Code You can use VS Code to work on individual files for quick edits, or you can open a folder as a workspace . Start with a new folder so that the tutorial files and Git history are separate from your other projects.
Create an empty folder named vscode101 outside any existing Git repository. Open Visual Studio Code, and then select File > Open Folder... . Select the vscode101 folder, and then select Select Folder ( Open on macOS). VS Code now considers the folder a workspace. On the Workspace Trust dialog, select Yes, I trust the authors . Important Workspace Trust lets you decide whether code in your project folder can run in VS Code.
When you download code from the internet, review it before you trust the folder. Learn more about Workspace Trust . Confirm that the Explorer view shows the vscode101 folder. You use the Explorer view to view and manage the files and folders in your workspace. Tip When you open a folder, VS Code can restore its open files, active view, and editor layout. You can also configure settings and debug configurations for only that folder.
Learn more about workspaces . Explore the user interface Take a quick tour of the user interface before you create the app. Switch between views with the Activity Bar Use the Activity Bar to switch between views. Tip Hover over an Activity Bar item to see its name and keyboard shortcut. Select the item again to close the view. Notice that the Primary Side Bar changes to show information for the selected view. For example, the Run and Debug view contains controls for configuring and starting a debugging session.
View and edit files with the Editor Select the Explorer view in the Activity Bar, and then select New File... . Enter index.html , and then press Enter . The new file opens in an Editor in the main area of the window. Type <h1>My recipes</h1> . As you type, IntelliSense suggests ways to complete your code. Use Up and Down to navigate the suggestions, and use Tab to insert a selected suggestion. Save the file with ⌘S (Windows, Linux Ctrl+S ) .
Select New File... again to create style.css , and then create app.js . Each file opens in a new Editor tab. You can open multiple editors and view them side by side. Learn more about side-by-side editing . Access the terminal from the Panel Open the integrated terminal with ⌃` (Windows, Linux Ctrl+` ) . You can also select View > Terminal . You can choose from the shells installed on your computer, such as PowerShell, Command Prompt, or Bash.
Enter the following command to create a file in the workspace. echo "Hello, VS Code" > greetings.txt The terminal starts in the root of your workspace by default. Notice that the Explorer view automatically shows the new file. Select the Launch Profile dropdown to view the available shells and open another terminal. Access commands with the Command Palette Open the Command Palette with ⇧⌘P (Windows, Linux Ctrl+Shift+P ) .
You can also select View > Command Palette . The Command Palette provides access to many VS Code commands. Extensions can add more commands. Try these Command Palette modes: Command mode ( > ) : after the > symbol, type move terminal to find commands that move the terminal to a new window. Quick Open mode : remove the > symbol, and then type a file name to search your workspace. Open Quick Open directly with ⌘P (Windows, Linux Ctrl+P ) .
Symbol search mode ( # ) : replace the > symbol with # to search for symbols such as variables and functions. Tip The Command Palette uses fuzzy matching. For example, typing odks finds the Open Default Keyboard Shortcuts command. Create a recipe app Replace the contents of the three files with the following fixed sample. Keeping the file names and code consistent makes it easier to follow the preview and debugging exercises.
Open index.html , replace its contents with the following HTML, and save the file with ⌘S (Windows, Linux Ctrl+S ) . <! DOCTYPE html > < html lang = "en" > < head > < meta charset = "UTF-8" > < meta name = "viewport" content = "width=device-width, initial-scale=1.0" > < title > Recipe list </ title > < link rel = "stylesheet" href = "style.css" > < script src = "app.js" defer ></ script > </ head > < body > < main > < h1 > My recipes </ h1 > < form id = "recipe-form" > < label for = "recipe-name" > Recipe name </ label > < input id = "recipe-name" name = "recipe-name" required > < label for = "recipe-description" > Description </ label > < textarea id = "recipe-description" name = "recipe-description" required ></ textarea > < button type = "submit" > Add recipe </ button > </ form > < ul id = "recipe-list" aria-live = "polite" ></ ul > </ main > </ body > </ html > Open style.css , add the following CSS, and save the file. :root { color-scheme : light dark ; font-family : system-ui , sans-serif ; } body { margin : 0 ; padding : 2rem ; } main { max-width : 40rem ; margin : 0 auto ; } form { display : grid ; gap : 0.75rem ; } input , textarea , button { font : inherit ; padding : 0.6rem ; } li { display : flex ; gap : 1rem ; justify-content : space-between ; margin-block : 1rem ; } Open app.js , add the following JavaScript, and save the file. const form = document . querySelector ( '#recipe-form' ); const nameInput = document . querySelector ( '#recipe-name' ); const descriptionInput = document . querySelector ( '#recipe-description' ); const recipeList = document . querySelector ( '#recipe-list' ); function addRecipe ( event ) { event . preventDefault (); const name = nameInput . value . trim (); const description = descriptionInput . value . trim (); if (! name || ! description ) { const emptyInput = ! name ? nameInput : descriptionInput ; emptyInput . setCustomValidity ( 'Enter at least one non-space character.' ); emptyInput . reportValidity (); emptyInput . addEventListener ( 'input' , () => emptyInput . setCustomValidity ( '' ), { once: true }); return ; } const item = document . createElement ( 'li' ); const recipeText = document . createElement ( 'span' ); recipeText . textContent = ` ${ name } : ${ description } ` ; const deleteButton = document . createElement ( 'button' ); deleteButton . type = 'button' ; deleteButton . textContent = 'Delete' ; deleteButton . setAttribute ( 'aria-label' , `Delete ${ name } ` ); deleteButton . addEventListener ( 'click' , () => item . remove ()); item . append ( recipeText , deleteButton ); recipeList . append ( item ); form . reset (); nameInput . focus (); } form . addEventListener ( 'submit' , addRecipe ); You now have a complete app in plain local files.
The textContent property displays recipe input as text instead of interpreting it as HTML. Preview the app in the integrated browser The built-in integrated browser opens local HTML files directly in VS Code. You don't need an extension, develop
The rest of this page is on the live site.