CINXE.COM
Basic Editing in Visual Studio Code
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="awa-expId" content="vscw_aaflight1016_control:103441;" /> <meta name="awa-env" content="prod" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="google-site-verification" content="hNs7DXrTySP_X-0P_AC0WulAXvUwgSXEmgfcO2r79dw" /> <!-- Twitter and Facebook OpenGraph Metadata--> <meta name="twitter:card" content="summary_large_image" /> <meta name="twitter:site" content="@code" /> <meta name="description" content="Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting." /> <meta name="keywords" content="" /> <meta name="ms.prod" content="vs-code" /> <meta name="ms.TOCTitle" content="Basic Editing" /> <meta name="ms.ContentId" content="DE4EAE2F-4542-4363-BB74-BE47D64141E6" /> <meta name="ms.date" content="10/29/2024" /> <meta name="ms.topic" content="conceptual" /> <!-- Twitter and Facebook OpenGraph Metadata--> <meta name="twitter:card" content="summary_large_image" /> <meta property="og:url" content="https://code.visualstudio.com/docs/editor/codebasics" /> <meta property="og:type" content="article" /> <meta property="og:title" content="Basic Editing in Visual Studio Code" /> <meta property="og:description" content="Learn about the basic editing features of Visual Studio Code. Search, multiple selection, code formatting." /> <meta property="og:image" content="https://code.visualstudio.com/assets/docs/editor/codebasics/code-basics-social.png" /> <link rel="shortcut icon" href="/favicon.ico" sizes="128x128" /> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <title>Basic Editing in Visual Studio Code</title> <link rel="stylesheet" href="/vendor/bootstrap/css/bootstrap.min.css"> <link rel="stylesheet" href="/dist/v2/style.css"> <script src="https://consentdeliveryfd.azurefd.net/mscc/lib/v2/wcp-consent.js"></script> <script type="text/javascript" src="https://js.monitor.azure.com/scripts/c/ms.analytics-web-4.min.js"></script> <script type="text/javascript"> // Leave as var; siteConsent is initialized and referenced elsewhere. var siteConsent = null; const GPC_DataSharingOptIn = false; WcpConsent.onInitCallback(function () { window.appInsights = new oneDS.ApplicationInsights(); window.appInsights.initialize({ instrumentationKey: "1a3eb3104447440391ad5f2a6ee06a0a-62879566-bc58-4741-9650-302bf2af703f-7103", propertyConfiguration: { userConsented: false, gpcDataSharingOptIn: false, callback: { userConsentDetails: siteConsent ? siteConsent.getConsent : undefined }, }, cookieCfg: { ignoreCookies: ["MSCC"] }, webAnalyticsConfiguration:{ // Web Analytics Plugin configuration urlCollectQuery: true, urlCollectHash: true, autoCapture: { scroll: true, pageView: true, onLoad: true, onUnload: true, click: true, resize: true, jsError: true } } }, []); window.appInsights.getPropertyManager().getPropertiesContext().web.gpcDataSharingOptIn = GPC_DataSharingOptIn; }); </script> <link rel="alternate" type="application/atom+xml" title="RSS Feed for code.visualstudio.com" href="/feed.xml" /> </head> <body > <!-- Setting theme here to avoid FOUC --> <script> function setTheme(themeName) { if (themeName === 'dark') { document.documentElement.removeAttribute('data-theme'); // dark is default, so no data-theme attribute needed } if (themeName === 'light') { document.documentElement.setAttribute('data-theme', themeName); } return; } // Determine initial theme: user preference or system preference let theme = localStorage.getItem('theme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); setTheme(theme); // Apply the initial theme // Listen for changes in the system theme preference window.matchMedia('(prefers-color-scheme: dark)').addListener(e => { if (!localStorage.getItem('theme')) { // Only if no user preference is saved setTheme(e.matches ? 'dark' : 'light'); } }); </script> <div id="main"> <div class="navbar-fixed-container"> <div class="navbar navbar-inverse navbar-fixed-top " data-spy="affix" data-offset-top="1"> <div id='cookie-banner'></div> <nav role="navigation" aria-label="Top Level"> <div class="container"> <div class="nav navbar-header"> <a class="navbar-brand" href="/"><span>Visual Studio Code</span></a> <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse" aria-label="Expand and Collapse Menu"> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <div class="navbar-collapse collapse"> <ul class="nav navbar-nav navbar-left"> <li class="active" ><a id="nav-docs" href="/docs">Docs</a></li> <li ><a id="nav-updates" href="/updates">Updates</a></li> <li ><a id="nav-blogs" href="/blogs">Blog</a></li> <li ><a id="nav-extend" href="/api">API</a></li> <li><a href="https://marketplace.visualstudio.com/VSCode" target="_blank" rel="noopener" id="nav-extensions">Extensions</a></li> <li ><a id="nav-faqs" href="/docs/supporting/faq">FAQ</a></li> <li class='search visible-xs visible-sm' ><a href="/Search">Search</a></li> <li ><a id="nav-copilot" href="/docs/copilot/overview">GitHub Copilot</a></li> </ul> </ul> <ul class="nav navbar-nav navbar-right" role="presentation"> <li> <button type="button" class="theme-switch" id="theme-toggle"> <img class="theme-icon-light" src="/assets/icons/theme-light.svg" alt="Switch to the dark theme" /> <img class="theme-icon-dark" src="/assets/icons/theme-dark.svg" alt="Switch to the light theme" /> </button> </li> <li> <a href="/Search" title="Search" class="btn search-btn" id="nav-search"> <img class="search-icon-light" src="/assets/icons/search.svg" width="16px" height="16px" alt="Search" /> <img class="search-icon-dark" src="/assets/icons/search-dark.svg" width="16px" height="16px" alt="Search" /> </a> </li> <li class="search" role="presentation"> <form class="nav-search search-form" role="search" aria-label="Search"> <div class="input-group" role="presentation"> <input type="text" name="q" class="search-box form-control" placeholder="Search Docs" aria-label="Search text"/> <span class="input-group-btn"> <button tabindex="0" class="btn" type="submit" aria-label="Search"> <img class="search-icon-dark" src="/assets/icons/search-dark.svg" alt="Search" /> <img class="search-icon-light" src="/assets/icons/search.svg" alt="Search" /> </button> </span> </div> </form> </li> <!-- this was hiden in the home and download page, keeping it for now --> <li><a class="link-button" href="/Download" id="nav-download"> <span>Download</span></a></li> </ul> </div> </div> </nav> </div> </div> <div class="updates-banner "> <div class="container"> <p class="message"><a href="/updates" id="banner-link-updates">Version 1.95</a> is now available! Read about the new features and fixes from October.</p> </div> <div tabindex="0" role="button" title="Dismiss this update" class="dismiss-btn" id="banner-dismiss-btn"><span class="sr-only">Dismiss this update</span><span aria-hidden="true" class="glyph-icon"></span></div> </div> <!-- This div wraps around the entire site --> <!-- The body itself should already have a main tag --> <div id="main-content"> <script> function closeReportIssue() { var element = document.getElementById('surveypopup'); element.parentElement.removeChild(element); } function reportIssue(tutorial, page) { var div = document.createElement('div'); div.innerHTML = '<div id="surveypopup" class="overlay visible"><div class="surveypopup"><div id="surveytitle">Tell us more<a href="javascript:void(0)" onclick="closeReportIssue()">X</a></div><div id="surveydiv"><iframe frameBorder="0" scrolling="0" src="https://www.research.net/r/PWZWZ52?tutorial=' + tutorial + '&step=' + page + '"></iframe></div></div></div>'; document.body.appendChild(div.children[0]); } </script> <div class="container body-content docs"> <div class="row"> <!-- left nav --> <div class="col-xs-12 col-md-2 docs-navbar-container"> <nav id="docs-navbar" aria-label="Topics" class="docs-nav visible-md visible-lg"> <ul class="nav" id="main-nav"> <li > <a class="docs-home" href="/docs" >Overview</a> </li> <li class="panel collapsed"> <a class="area" role="button" href="#setup-articles" data-parent="#main-nav" data-toggle="collapse">Setup</a> <ul id="setup-articles" class="collapse "> <li > <a href="/docs/setup/setup-overview" >Overview</a> </li> <li > <a href="/docs/setup/linux" >Linux</a> </li> <li > <a href="/docs/setup/mac" >macOS</a> </li> <li > <a href="/docs/setup/windows" >Windows</a> </li> <li > <a href="/docs/setup/raspberry-pi" >Raspberry Pi</a> </li> <li > <a href="/docs/setup/network" >Network</a> </li> <li > <a href="/docs/setup/additional-components" >Additional Components</a> </li> <li > <a href="/docs/setup/enterprise" >Enterprise</a> </li> <li > <a href="/docs/setup/uninstall" >Uninstall</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#getstarted-articles" data-parent="#main-nav" data-toggle="collapse">Get Started</a> <ul id="getstarted-articles" class="collapse "> <li > <a href="/docs/getstarted/getting-started" >Tutorial</a> </li> <li > <a href="/docs/getstarted/introvideos" >Intro Videos</a> </li> <li > <a href="/docs/getstarted/tips-and-tricks" >Tips and Tricks</a> </li> <li > <a href="/docs/getstarted/userinterface" >User Interface</a> </li> <li > <a href="/docs/getstarted/themes" >Themes</a> </li> <li > <a href="/docs/getstarted/settings" >Settings</a> </li> <li > <a href="/docs/getstarted/keybindings" >Key Bindings</a> </li> <li > <a href="/docs/getstarted/locales" >Display Language</a> </li> <li > <a href="/docs/getstarted/telemetry" >Telemetry</a> </li> <li > <a href="/docs/getstarted/educators-and-students" >Educators & Students</a> </li> </ul> </li> <li class="panel active expanded"> <a class="area" role="button" href="#editor-articles" data-parent="#main-nav" data-toggle="collapse">User Guide</a> <ul id="editor-articles" class="collapse in"> <li class="active"> <a href="/docs/editor/codebasics" aria-label="Current Page: Basic Editing">Basic Editing</a> </li> <li > <a href="/docs/editor/extension-marketplace" >Extension Marketplace</a> </li> <li > <a href="/docs/editor/intellisense" >IntelliSense</a> </li> <li > <a href="/docs/editor/editingevolved" >Code Navigation</a> </li> <li > <a href="/docs/editor/refactoring" >Refactoring</a> </li> <li > <a href="/docs/editor/debugging" >Debugging</a> </li> <li > <a href="/docs/editor/testing" >Testing</a> </li> <li > <a href="/docs/editor/vscode-web" >VS Code for the Web</a> </li> <li > <a href="/docs/editor/tasks" >Tasks</a> </li> <li > <a href="/docs/editor/profiles" >Profiles</a> </li> <li > <a href="/docs/editor/settings-sync" >Settings Sync</a> </li> <li > <a href="/docs/editor/userdefinedsnippets" >Snippets</a> </li> <li > <a href="/docs/editor/emmet" >Emmet</a> </li> <li > <a href="/docs/editor/command-line" >Command Line Interface</a> </li> <li > <a href="/docs/editor/workspaces" >Workspaces</a> </li> <li > <a href="/docs/editor/workspace-trust" >Workspace Trust</a> </li> <li > <a href="/docs/editor/multi-root-workspaces" >Multi-root Workspaces</a> </li> <li > <a href="/docs/editor/accessibility" >Accessibility</a> </li> <li > <a href="/docs/editor/voice" >Voice Interactions</a> </li> <li > <a href="/docs/editor/custom-layout" >Custom Layout</a> </li> <li > <a href="/docs/editor/port-forwarding" >Port Forwarding</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#sourcecontrol-articles" data-parent="#main-nav" data-toggle="collapse">Source Control</a> <ul id="sourcecontrol-articles" class="collapse "> <li > <a href="/docs/sourcecontrol/overview" >Overview</a> </li> <li > <a href="/docs/sourcecontrol/intro-to-git" >Introduction to Git</a> </li> <li > <a href="/docs/sourcecontrol/github" >Collaborate on GitHub</a> </li> <li > <a href="/docs/sourcecontrol/faq" >FAQ</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#terminal-articles" data-parent="#main-nav" data-toggle="collapse">Terminal</a> <ul id="terminal-articles" class="collapse "> <li > <a href="/docs/terminal/getting-started" >Getting Started Tutorial</a> </li> <li > <a href="/docs/terminal/basics" >Terminal Basics</a> </li> <li > <a href="/docs/terminal/profiles" >Terminal Profiles</a> </li> <li > <a href="/docs/terminal/shell-integration" >Shell Integration</a> </li> <li > <a href="/docs/terminal/appearance" >Appearance</a> </li> <li > <a href="/docs/terminal/advanced" >Advanced</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#copilot-articles" data-parent="#main-nav" data-toggle="collapse">GitHub Copilot</a> <ul id="copilot-articles" class="collapse "> <li > <a href="/docs/copilot/overview" >Overview</a> </li> <li > <a href="/docs/copilot/copilot-vscode-features" >Copilot Cheat Sheet</a> </li> <li > <a href="/docs/copilot/setup" >Setup</a> </li> <li > <a href="/docs/copilot/getting-started" >Quickstart</a> </li> <li > <a href="/docs/copilot/ai-powered-suggestions" >Code Completions</a> </li> <li > <a href="/docs/copilot/copilot-chat" >Copilot Chat</a> </li> <li > <a href="/docs/copilot/getting-started-chat" >Copilot Chat Tutorial</a> </li> <li > <a href="/docs/copilot/copilot-edits" >Copilot Edits</a> </li> <li > <a href="/docs/copilot/prompt-crafting" >Best Practices</a> </li> <li > <a href="/docs/copilot/workspace-context" >Workspace Context</a> </li> <li > <a href="/docs/copilot/copilot-customization" >Customizing Copilot</a> </li> <li > <a href="/docs/copilot/copilot-extensibility-overview" >Copilot Extensibility</a> </li> <li > <a href="/docs/copilot/copilot-settings" >Settings Reference</a> </li> <li > <a href="/docs/copilot/faq" >FAQ</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#languages-articles" data-parent="#main-nav" data-toggle="collapse">Languages</a> <ul id="languages-articles" class="collapse "> <li > <a href="/docs/languages/overview" >Overview</a> </li> <li > <a href="/docs/languages/javascript" >JavaScript</a> </li> <li > <a href="/docs/languages/json" >JSON</a> </li> <li > <a href="/docs/languages/html" >HTML</a> </li> <li > <a href="/docs/languages/css" >CSS, SCSS and Less</a> </li> <li > <a href="/docs/languages/typescript" >TypeScript</a> </li> <li > <a href="/docs/languages/markdown" >Markdown</a> </li> <li > <a href="/docs/languages/powershell" >PowerShell</a> </li> <li > <a href="/docs/languages/cpp" >C++</a> </li> <li > <a href="/docs/languages/java" >Java</a> </li> <li > <a href="/docs/languages/php" >PHP</a> </li> <li > <a href="/docs/languages/python" >Python</a> </li> <li > <a href="/docs/languages/julia" >Julia</a> </li> <li > <a href="/docs/languages/r" >R</a> </li> <li > <a href="/docs/languages/ruby" >Ruby</a> </li> <li > <a href="/docs/languages/rust" >Rust</a> </li> <li > <a href="/docs/languages/go" >Go</a> </li> <li > <a href="/docs/languages/tsql" >T-SQL</a> </li> <li > <a href="/docs/languages/csharp" >C#</a> </li> <li > <a href="/docs/languages/dotnet" >.NET</a> </li> <li > <a href="/docs/languages/polyglot" >Polyglot</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#nodejs-articles" data-parent="#main-nav" data-toggle="collapse">Node.js / JavaScript</a> <ul id="nodejs-articles" class="collapse "> <li > <a href="/docs/nodejs/working-with-javascript" >Working with JavaScript</a> </li> <li > <a href="/docs/nodejs/nodejs-tutorial" >Node.js Tutorial</a> </li> <li > <a href="/docs/nodejs/nodejs-debugging" >Node.js Debugging</a> </li> <li > <a href="/docs/nodejs/nodejs-deployment" >Deploy Node.js Apps</a> </li> <li > <a href="/docs/nodejs/browser-debugging" >Browser Debugging</a> </li> <li > <a href="/docs/nodejs/angular-tutorial" >Angular Tutorial</a> </li> <li > <a href="/docs/nodejs/reactjs-tutorial" >React Tutorial</a> </li> <li > <a href="/docs/nodejs/vuejs-tutorial" >Vue Tutorial</a> </li> <li > <a href="/docs/nodejs/debugging-recipes" >Debugging Recipes</a> </li> <li > <a href="/docs/nodejs/profiling" >Performance Profiling</a> </li> <li > <a href="/docs/nodejs/extensions" >Extensions</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#typescript-articles" data-parent="#main-nav" data-toggle="collapse">TypeScript</a> <ul id="typescript-articles" class="collapse "> <li > <a href="/docs/typescript/typescript-tutorial" >Tutorial</a> </li> <li > <a href="/docs/typescript/typescript-compiling" >Compiling</a> </li> <li > <a href="/docs/typescript/typescript-editing" >Editing</a> </li> <li > <a href="/docs/typescript/typescript-refactoring" >Refactoring</a> </li> <li > <a href="/docs/typescript/typescript-debugging" >Debugging</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#python-articles" data-parent="#main-nav" data-toggle="collapse">Python</a> <ul id="python-articles" class="collapse "> <li > <a href="/docs/python/python-quick-start" >Quick Start</a> </li> <li > <a href="/docs/python/python-tutorial" >Tutorial</a> </li> <li > <a href="/docs/python/run" >Run Python Code</a> </li> <li > <a href="/docs/python/editing" >Editing Code</a> </li> <li > <a href="/docs/python/linting" >Linting</a> </li> <li > <a href="/docs/python/formatting" >Formatting</a> </li> <li > <a href="/docs/python/debugging" >Debugging</a> </li> <li > <a href="/docs/python/environments" >Environments</a> </li> <li > <a href="/docs/python/testing" >Testing</a> </li> <li > <a href="/docs/python/jupyter-support-py" >Python Interactive</a> </li> <li > <a href="/docs/python/tutorial-django" >Django Tutorial</a> </li> <li > <a href="/docs/python/tutorial-fastapi" >FastAPI Tutorial</a> </li> <li > <a href="/docs/python/tutorial-flask" >Flask Tutorial</a> </li> <li > <a href="/docs/python/tutorial-create-containers" >Create containers</a> </li> <li > <a href="/docs/python/python-on-azure" >Deploy Python Apps</a> </li> <li > <a href="/docs/python/python-web" >Python in the Web</a> </li> <li > <a href="/docs/python/settings-reference" >Settings Reference</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#java-articles" data-parent="#main-nav" data-toggle="collapse">Java</a> <ul id="java-articles" class="collapse "> <li > <a href="/docs/java/java-tutorial" >Getting Started</a> </li> <li > <a href="/docs/java/java-editing" >Navigate and Edit</a> </li> <li > <a href="/docs/java/java-refactoring" >Refactoring</a> </li> <li > <a href="/docs/java/java-linting" >Formatting and Linting</a> </li> <li > <a href="/docs/java/java-project" >Project Management</a> </li> <li > <a href="/docs/java/java-build" >Build Tools</a> </li> <li > <a href="/docs/java/java-debugging" >Run and Debug</a> </li> <li > <a href="/docs/java/java-testing" >Testing</a> </li> <li > <a href="/docs/java/java-spring-boot" >Spring Boot</a> </li> <li > <a href="/docs/java/java-tomcat-jetty" >Application Servers</a> </li> <li > <a href="/docs/java/java-on-azure" >Deploy Java Apps</a> </li> <li > <a href="/docs/java/java-gui" >GUI Applications</a> </li> <li > <a href="/docs/java/extensions" >Extensions</a> </li> <li > <a href="/docs/java/java-faq" >FAQ</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#cpp-articles" data-parent="#main-nav" data-toggle="collapse">C++</a> <ul id="cpp-articles" class="collapse "> <li > <a href="/docs/cpp/introvideos-cpp" >Intro Videos</a> </li> <li > <a href="/docs/cpp/config-linux" >GCC on Linux</a> </li> <li > <a href="/docs/cpp/config-mingw" >GCC on Windows</a> </li> <li > <a href="/docs/cpp/config-wsl" >GCC on Windows Subsystem for Linux</a> </li> <li > <a href="/docs/cpp/config-clang-mac" >Clang on macOS</a> </li> <li > <a href="/docs/cpp/config-msvc" >Microsoft C++ on Windows</a> </li> <li > <a href="/docs/cpp/build-with-cmake" >Build with CMake</a> </li> <li > <a href="/docs/cpp/cmake-linux" >CMake Tools on Linux</a> </li> <li > <a href="/docs/cpp/cmake-quickstart" >CMake Quick Start</a> </li> <li > <a href="/docs/cpp/cpp-ide" >Editing and Navigating</a> </li> <li > <a href="/docs/cpp/cpp-debug" >Debugging</a> </li> <li > <a href="/docs/cpp/cpp-refactoring" >Refactoring</a> </li> <li > <a href="/docs/cpp/launch-json-reference" >Configure debugging</a> </li> <li > <a href="/docs/cpp/customize-default-settings-cpp" >Settings</a> </li> <li > <a href="/docs/cpp/configure-intellisense" >Configure IntelliSense</a> </li> <li > <a href="/docs/cpp/configure-intellisense-crosscompilation" >Configure IntelliSense for cross-compiling</a> </li> <li > <a href="/docs/cpp/faq-cpp" >FAQ</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#csharp-articles" data-parent="#main-nav" data-toggle="collapse">C#</a> <ul id="csharp-articles" class="collapse "> <li > <a href="/docs/csharp/introvideos-csharp" >Intro Videos</a> </li> <li > <a href="/docs/csharp/get-started" >Get Started</a> </li> <li > <a href="/docs/csharp/navigate-edit" >Navigate and Edit</a> </li> <li > <a href="/docs/csharp/intellicode" >IntelliCode</a> </li> <li > <a href="/docs/csharp/refactoring" >Refactoring</a> </li> <li > <a href="/docs/csharp/formatting-linting" >Formatting and Linting</a> </li> <li > <a href="/docs/csharp/project-management" >Project Management</a> </li> <li > <a href="/docs/csharp/build-tools" >Build Tools</a> </li> <li > <a href="/docs/csharp/package-management" >Package Management</a> </li> <li > <a href="/docs/csharp/debugging" >Run and Debug</a> </li> <li > <a href="/docs/csharp/testing" >Testing</a> </li> <li > <a href="/docs/csharp/cs-dev-kit-faq" >FAQ</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#containers-articles" data-parent="#main-nav" data-toggle="collapse">Docker</a> <ul id="containers-articles" class="collapse "> <li > <a href="/docs/containers/overview" >Overview</a> </li> <li > <a href="/docs/containers/quickstart-node" >Node.js</a> </li> <li > <a href="/docs/containers/quickstart-python" >Python</a> </li> <li > <a href="/docs/containers/quickstart-aspnet-core" >ASP.NET Core</a> </li> <li > <a href="/docs/containers/debug-common" >Debug</a> </li> <li > <a href="/docs/containers/docker-compose" >Docker Compose</a> </li> <li > <a href="/docs/containers/quickstart-container-registries" >Registries</a> </li> <li > <a href="/docs/containers/app-service" >Deploy to Azure</a> </li> <li > <a href="/docs/containers/choosing-dev-environment" >Choose a dev environment</a> </li> <li > <a href="/docs/containers/reference" >Customize</a> </li> <li > <a href="/docs/containers/bridge-to-kubernetes" >Develop with Kubernetes</a> </li> <li > <a href="/docs/containers/troubleshooting" >Tips and Tricks</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#datascience-articles" data-parent="#main-nav" data-toggle="collapse">Data Science</a> <ul id="datascience-articles" class="collapse "> <li > <a href="/docs/datascience/overview" >Overview</a> </li> <li > <a href="/docs/datascience/jupyter-notebooks" >Jupyter Notebooks</a> </li> <li > <a href="/docs/datascience/data-science-tutorial" >Data Science Tutorial</a> </li> <li > <a href="/docs/datascience/python-interactive" >Python Interactive</a> </li> <li > <a href="/docs/datascience/data-wrangler-quick-start" >Data Wrangler Quick Start</a> </li> <li > <a href="/docs/datascience/data-wrangler" >Data Wrangler</a> </li> <li > <a href="/docs/datascience/pytorch-support" >PyTorch Support</a> </li> <li > <a href="/docs/datascience/azure-machine-learning" >Azure Machine Learning</a> </li> <li > <a href="/docs/datascience/jupyter-kernel-management" >Manage Jupyter Kernels</a> </li> <li > <a href="/docs/datascience/notebooks-web" >Jupyter Notebooks on the web</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#azure-articles" data-parent="#main-nav" data-toggle="collapse">Azure</a> <ul id="azure-articles" class="collapse "> <li > <a href="/docs/azure/overview" >Overview</a> </li> <li > <a href="/docs/azure/gettingstarted" >Getting Started</a> </li> <li > <a href="/docs/azure/deployment" >Deployment</a> </li> <li > <a href="/docs/azure/docker" >Docker</a> </li> <li > <a href="/docs/azure/aksextensions" >Azure Kubernetes Service</a> </li> <li > <a href="/docs/azure/kubernetes" >Kubernetes</a> </li> <li > <a href="/docs/azure/mongodb" >MongoDB</a> </li> <li > <a href="/docs/azure/remote-debugging" >Remote Debugging for Node.js</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#remote-articles" data-parent="#main-nav" data-toggle="collapse">Remote</a> <ul id="remote-articles" class="collapse "> <li > <a href="/docs/remote/remote-overview" >Overview</a> </li> <li > <a href="/docs/remote/ssh" >SSH</a> </li> <li > <a href="/docs/remote/dev-containers" >Dev Containers</a> </li> <li > <a href="/docs/remote/wsl" >Windows Subsystem for Linux</a> </li> <li > <a href="/docs/remote/codespaces" >GitHub Codespaces</a> </li> <li > <a href="/docs/remote/vscode-server" >VS Code Server</a> </li> <li > <a href="/docs/remote/tunnels" >Tunnels</a> </li> <li > <a href="/docs/remote/ssh-tutorial" >SSH Tutorial</a> </li> <li > <a href="/docs/remote/wsl-tutorial" >WSL Tutorial</a> </li> <li > <a href="/docs/remote/troubleshooting" >Tips and Tricks</a> </li> <li > <a href="/docs/remote/faq" >FAQ</a> </li> </ul> </li> <li class="panel collapsed"> <a class="area" role="button" href="#devcontainers-articles" data-parent="#main-nav" data-toggle="collapse">Dev Containers</a> <ul id="devcontainers-articles" class="collapse "> <li > <a href="/docs/devcontainers/containers" >Overview</a> </li> <li > <a href="/docs/devcontainers/tutorial" >Tutorial</a> </li> <li > <a href="/docs/devcontainers/attach-container" >Attach to Container</a> </li> <li > <a href="/docs/devcontainers/create-dev-container" >Create a Dev Container</a> </li> <li > <a href="/docs/devcontainers/containers-advanced" >Advanced Containers</a> </li> <li > <a href="/docs/devcontainers/devcontainerjson-reference" >devcontainer.json</a> </li> <li > <a href="/docs/devcontainers/devcontainer-cli" >Dev Container CLI</a> </li> <li > <a href="/docs/devcontainers/tips-and-tricks" >Tips and Tricks</a> </li> <li > <a href="/docs/devcontainers/faq" >FAQ</a> </li> </ul> </li> </ul> </nav> <nav id="small-nav" aria-label="Topics" class="docs-nav hidden-md hidden-lg"> <label class="faux-h4" for="small-nav-dropdown">Topics</label> <select id="small-nav-dropdown" aria-label="topics"> <option value="/docs" >Overview</option> <optgroup label="Setup"> <option value="/docs/setup/setup-overview" >Overview</option> <option value="/docs/setup/linux" >Linux</option> <option value="/docs/setup/mac" >macOS</option> <option value="/docs/setup/windows" >Windows</option> <option value="/docs/setup/raspberry-pi" >Raspberry Pi</option> <option value="/docs/setup/network" >Network</option> <option value="/docs/setup/additional-components" >Additional Components</option> <option value="/docs/setup/enterprise" >Enterprise</option> <option value="/docs/setup/uninstall" >Uninstall</option> </optgroup> <optgroup label="Get Started"> <option value="/docs/getstarted/getting-started" >Tutorial</option> <option value="/docs/getstarted/introvideos" >Intro Videos</option> <option value="/docs/getstarted/tips-and-tricks" >Tips and Tricks</option> <option value="/docs/getstarted/userinterface" >User Interface</option> <option value="/docs/getstarted/themes" >Themes</option> <option value="/docs/getstarted/settings" >Settings</option> <option value="/docs/getstarted/keybindings" >Key Bindings</option> <option value="/docs/getstarted/locales" >Display Language</option> <option value="/docs/getstarted/telemetry" >Telemetry</option> <option value="/docs/getstarted/educators-and-students" >Educators & Students</option> </optgroup> <optgroup label="User Guide"> <option value="/docs/editor/codebasics" selected>Basic Editing</option> <option value="/docs/editor/extension-marketplace" >Extension Marketplace</option> <option value="/docs/editor/intellisense" >IntelliSense</option> <option value="/docs/editor/editingevolved" >Code Navigation</option> <option value="/docs/editor/refactoring" >Refactoring</option> <option value="/docs/editor/debugging" >Debugging</option> <option value="/docs/editor/testing" >Testing</option> <option value="/docs/editor/vscode-web" >VS Code for the Web</option> <option value="/docs/editor/tasks" >Tasks</option> <option value="/docs/editor/profiles" >Profiles</option> <option value="/docs/editor/settings-sync" >Settings Sync</option> <option value="/docs/editor/userdefinedsnippets" >Snippets</option> <option value="/docs/editor/emmet" >Emmet</option> <option value="/docs/editor/command-line" >Command Line Interface</option> <option value="/docs/editor/workspaces" >Workspaces</option> <option value="/docs/editor/workspace-trust" >Workspace Trust</option> <option value="/docs/editor/multi-root-workspaces" >Multi-root Workspaces</option> <option value="/docs/editor/accessibility" >Accessibility</option> <option value="/docs/editor/voice" >Voice Interactions</option> <option value="/docs/editor/custom-layout" >Custom Layout</option> <option value="/docs/editor/port-forwarding" >Port Forwarding</option> </optgroup> <optgroup label="Source Control"> <option value="/docs/sourcecontrol/overview" >Overview</option> <option value="/docs/sourcecontrol/intro-to-git" >Introduction to Git</option> <option value="/docs/sourcecontrol/github" >Collaborate on GitHub</option> <option value="/docs/sourcecontrol/faq" >FAQ</option> </optgroup> <optgroup label="Terminal"> <option value="/docs/terminal/getting-started" >Getting Started Tutorial</option> <option value="/docs/terminal/basics" >Terminal Basics</option> <option value="/docs/terminal/profiles" >Terminal Profiles</option> <option value="/docs/terminal/shell-integration" >Shell Integration</option> <option value="/docs/terminal/appearance" >Appearance</option> <option value="/docs/terminal/advanced" >Advanced</option> </optgroup> <optgroup label="GitHub Copilot"> <option value="/docs/copilot/overview" >Overview</option> <option value="/docs/copilot/copilot-vscode-features" >Copilot Cheat Sheet</option> <option value="/docs/copilot/setup" >Setup</option> <option value="/docs/copilot/getting-started" >Quickstart</option> <option value="/docs/copilot/ai-powered-suggestions" >Code Completions</option> <option value="/docs/copilot/copilot-chat" >Copilot Chat</option> <option value="/docs/copilot/getting-started-chat" >Copilot Chat Tutorial</option> <option value="/docs/copilot/copilot-edits" >Copilot Edits</option> <option value="/docs/copilot/prompt-crafting" >Best Practices</option> <option value="/docs/copilot/workspace-context" >Workspace Context</option> <option value="/docs/copilot/copilot-customization" >Customizing Copilot</option> <option value="/docs/copilot/copilot-extensibility-overview" >Copilot Extensibility</option> <option value="/docs/copilot/copilot-settings" >Settings Reference</option> <option value="/docs/copilot/faq" >FAQ</option> </optgroup> <optgroup label="Languages"> <option value="/docs/languages/overview" >Overview</option> <option value="/docs/languages/javascript" >JavaScript</option> <option value="/docs/languages/json" >JSON</option> <option value="/docs/languages/html" >HTML</option> <option value="/docs/languages/css" >CSS, SCSS and Less</option> <option value="/docs/languages/typescript" >TypeScript</option> <option value="/docs/languages/markdown" >Markdown</option> <option value="/docs/languages/powershell" >PowerShell</option> <option value="/docs/languages/cpp" >C++</option> <option value="/docs/languages/java" >Java</option> <option value="/docs/languages/php" >PHP</option> <option value="/docs/languages/python" >Python</option> <option value="/docs/languages/julia" >Julia</option> <option value="/docs/languages/r" >R</option> <option value="/docs/languages/ruby" >Ruby</option> <option value="/docs/languages/rust" >Rust</option> <option value="/docs/languages/go" >Go</option> <option value="/docs/languages/tsql" >T-SQL</option> <option value="/docs/languages/csharp" >C#</option> <option value="/docs/languages/dotnet" >.NET</option> <option value="/docs/languages/polyglot" >Polyglot</option> </optgroup> <optgroup label="Node.js / JavaScript"> <option value="/docs/nodejs/working-with-javascript" >Working with JavaScript</option> <option value="/docs/nodejs/nodejs-tutorial" >Node.js Tutorial</option> <option value="/docs/nodejs/nodejs-debugging" >Node.js Debugging</option> <option value="/docs/nodejs/nodejs-deployment" >Deploy Node.js Apps</option> <option value="/docs/nodejs/browser-debugging" >Browser Debugging</option> <option value="/docs/nodejs/angular-tutorial" >Angular Tutorial</option> <option value="/docs/nodejs/reactjs-tutorial" >React Tutorial</option> <option value="/docs/nodejs/vuejs-tutorial" >Vue Tutorial</option> <option value="/docs/nodejs/debugging-recipes" >Debugging Recipes</option> <option value="/docs/nodejs/profiling" >Performance Profiling</option> <option value="/docs/nodejs/extensions" >Extensions</option> </optgroup> <optgroup label="TypeScript"> <option value="/docs/typescript/typescript-tutorial" >Tutorial</option> <option value="/docs/typescript/typescript-compiling" >Compiling</option> <option value="/docs/typescript/typescript-editing" >Editing</option> <option value="/docs/typescript/typescript-refactoring" >Refactoring</option> <option value="/docs/typescript/typescript-debugging" >Debugging</option> </optgroup> <optgroup label="Python"> <option value="/docs/python/python-quick-start" >Quick Start</option> <option value="/docs/python/python-tutorial" >Tutorial</option> <option value="/docs/python/run" >Run Python Code</option> <option value="/docs/python/editing" >Editing Code</option> <option value="/docs/python/linting" >Linting</option> <option value="/docs/python/formatting" >Formatting</option> <option value="/docs/python/debugging" >Debugging</option> <option value="/docs/python/environments" >Environments</option> <option value="/docs/python/testing" >Testing</option> <option value="/docs/python/jupyter-support-py" >Python Interactive</option> <option value="/docs/python/tutorial-django" >Django Tutorial</option> <option value="/docs/python/tutorial-fastapi" >FastAPI Tutorial</option> <option value="/docs/python/tutorial-flask" >Flask Tutorial</option> <option value="/docs/python/tutorial-create-containers" >Create containers</option> <option value="/docs/python/python-on-azure" >Deploy Python Apps</option> <option value="/docs/python/python-web" >Python in the Web</option> <option value="/docs/python/settings-reference" >Settings Reference</option> </optgroup> <optgroup label="Java"> <option value="/docs/java/java-tutorial" >Getting Started</option> <option value="/docs/java/java-editing" >Navigate and Edit</option> <option value="/docs/java/java-refactoring" >Refactoring</option> <option value="/docs/java/java-linting" >Formatting and Linting</option> <option value="/docs/java/java-project" >Project Management</option> <option value="/docs/java/java-build" >Build Tools</option> <option value="/docs/java/java-debugging" >Run and Debug</option> <option value="/docs/java/java-testing" >Testing</option> <option value="/docs/java/java-spring-boot" >Spring Boot</option> <option value="/docs/java/java-tomcat-jetty" >Application Servers</option> <option value="/docs/java/java-on-azure" >Deploy Java Apps</option> <option value="/docs/java/java-gui" >GUI Applications</option> <option value="/docs/java/extensions" >Extensions</option> <option value="/docs/java/java-faq" >FAQ</option> </optgroup> <optgroup label="C++"> <option value="/docs/cpp/introvideos-cpp" >Intro Videos</option> <option value="/docs/cpp/config-linux" >GCC on Linux</option> <option value="/docs/cpp/config-mingw" >GCC on Windows</option> <option value="/docs/cpp/config-wsl" >GCC on Windows Subsystem for Linux</option> <option value="/docs/cpp/config-clang-mac" >Clang on macOS</option> <option value="/docs/cpp/config-msvc" >Microsoft C++ on Windows</option> <option value="/docs/cpp/build-with-cmake" >Build with CMake</option> <option value="/docs/cpp/cmake-linux" >CMake Tools on Linux</option> <option value="/docs/cpp/cmake-quickstart" >CMake Quick Start</option> <option value="/docs/cpp/cpp-ide" >Editing and Navigating</option> <option value="/docs/cpp/cpp-debug" >Debugging</option> <option value="/docs/cpp/cpp-refactoring" >Refactoring</option> <option value="/docs/cpp/launch-json-reference" >Configure debugging</option> <option value="/docs/cpp/customize-default-settings-cpp" >Settings</option> <option value="/docs/cpp/configure-intellisense" >Configure IntelliSense</option> <option value="/docs/cpp/configure-intellisense-crosscompilation" >Configure IntelliSense for cross-compiling</option> <option value="/docs/cpp/faq-cpp" >FAQ</option> </optgroup> <optgroup label="C#"> <option value="/docs/csharp/introvideos-csharp" >Intro Videos</option> <option value="/docs/csharp/get-started" >Get Started</option> <option value="/docs/csharp/navigate-edit" >Navigate and Edit</option> <option value="/docs/csharp/intellicode" >IntelliCode</option> <option value="/docs/csharp/refactoring" >Refactoring</option> <option value="/docs/csharp/formatting-linting" >Formatting and Linting</option> <option value="/docs/csharp/project-management" >Project Management</option> <option value="/docs/csharp/build-tools" >Build Tools</option> <option value="/docs/csharp/package-management" >Package Management</option> <option value="/docs/csharp/debugging" >Run and Debug</option> <option value="/docs/csharp/testing" >Testing</option> <option value="/docs/csharp/cs-dev-kit-faq" >FAQ</option> </optgroup> <optgroup label="Docker"> <option value="/docs/containers/overview" >Overview</option> <option value="/docs/containers/quickstart-node" >Node.js</option> <option value="/docs/containers/quickstart-python" >Python</option> <option value="/docs/containers/quickstart-aspnet-core" >ASP.NET Core</option> <option value="/docs/containers/debug-common" >Debug</option> <option value="/docs/containers/docker-compose" >Docker Compose</option> <option value="/docs/containers/quickstart-container-registries" >Registries</option> <option value="/docs/containers/app-service" >Deploy to Azure</option> <option value="/docs/containers/choosing-dev-environment" >Choose a dev environment</option> <option value="/docs/containers/reference" >Customize</option> <option value="/docs/containers/bridge-to-kubernetes" >Develop with Kubernetes</option> <option value="/docs/containers/troubleshooting" >Tips and Tricks</option> </optgroup> <optgroup label="Data Science"> <option value="/docs/datascience/overview" >Overview</option> <option value="/docs/datascience/jupyter-notebooks" >Jupyter Notebooks</option> <option value="/docs/datascience/data-science-tutorial" >Data Science Tutorial</option> <option value="/docs/datascience/python-interactive" >Python Interactive</option> <option value="/docs/datascience/data-wrangler-quick-start" >Data Wrangler Quick Start</option> <option value="/docs/datascience/data-wrangler" >Data Wrangler</option> <option value="/docs/datascience/pytorch-support" >PyTorch Support</option> <option value="/docs/datascience/azure-machine-learning" >Azure Machine Learning</option> <option value="/docs/datascience/jupyter-kernel-management" >Manage Jupyter Kernels</option> <option value="/docs/datascience/notebooks-web" >Jupyter Notebooks on the web</option> </optgroup> <optgroup label="Azure"> <option value="/docs/azure/overview" >Overview</option> <option value="/docs/azure/gettingstarted" >Getting Started</option> <option value="/docs/azure/deployment" >Deployment</option> <option value="/docs/azure/docker" >Docker</option> <option value="/docs/azure/aksextensions" >Azure Kubernetes Service</option> <option value="/docs/azure/kubernetes" >Kubernetes</option> <option value="/docs/azure/mongodb" >MongoDB</option> <option value="/docs/azure/remote-debugging" >Remote Debugging for Node.js</option> </optgroup> <optgroup label="Remote"> <option value="/docs/remote/remote-overview" >Overview</option> <option value="/docs/remote/ssh" >SSH</option> <option value="/docs/remote/dev-containers" >Dev Containers</option> <option value="/docs/remote/wsl" >Windows Subsystem for Linux</option> <option value="/docs/remote/codespaces" >GitHub Codespaces</option> <option value="/docs/remote/vscode-server" >VS Code Server</option> <option value="/docs/remote/tunnels" >Tunnels</option> <option value="/docs/remote/ssh-tutorial" >SSH Tutorial</option> <option value="/docs/remote/wsl-tutorial" >WSL Tutorial</option> <option value="/docs/remote/troubleshooting" >Tips and Tricks</option> <option value="/docs/remote/faq" >FAQ</option> </optgroup> <optgroup label="Dev Containers"> <option value="/docs/devcontainers/containers" >Overview</option> <option value="/docs/devcontainers/tutorial" >Tutorial</option> <option value="/docs/devcontainers/attach-container" >Attach to Container</option> <option value="/docs/devcontainers/create-dev-container" >Create a Dev Container</option> <option value="/docs/devcontainers/containers-advanced" >Advanced Containers</option> <option value="/docs/devcontainers/devcontainerjson-reference" >devcontainer.json</option> <option value="/docs/devcontainers/devcontainer-cli" >Dev Container CLI</option> <option value="/docs/devcontainers/tips-and-tricks" >Tips and Tricks</option> <option value="/docs/devcontainers/faq" >FAQ</option> </optgroup> </select> </nav> </div> <!-- small right nav --> <div class="col-xs-12 visible-xs"> <nav aria-labelledby="small-right-nav-label" class="small-nav docs-nav updates-nav"> <label class="faux-h4" for="small-right-nav-dropdown" id="small-right-nav-label">In this article</label> <select id="small-right-nav-dropdown" class="small-nav-select" aria-label="Sections"> <option value="#_keyboard-shortcuts">Keyboard shortcuts</option> <option value="#_multiple-selections-multicursor">Multiple selections (multi-cursor)</option> <option value="#_column-box-selection">Column (box) selection</option> <option value="#_save-auto-save">Save / Auto Save</option> <option value="#_hot-exit">Hot Exit</option> <option value="#_find-and-replace">Find and Replace</option> <option value="#_search-across-files">Search across files</option> <option value="#_search-editor">Search Editor</option> <option value="#_intellisense">IntelliSense</option> <option value="#_formatting">Formatting</option> <option value="#_folding">Folding</option> <option value="#_indentation">Indentation</option> <option value="#_file-encoding-support">File encoding support</option> <option value="#_compare-files">Compare files</option> <option value="#_next-steps">Next steps</option> <option value="#_common-questions">Common questions</option> </select> </nav> </div> <!-- main content --> <main class="col-xs-12 col-sm-9 col-md-8 body"> <div class="edit-github pull-right"> <a href="https://vscode.dev/github/microsoft/vscode-docs/blob/main/docs/editor/codebasics.md" class="btn btn-default" title="Edit this document in vscode.dev"> <span class="glyphicon glyphicon-pencil"></span> <span class="hidden-xs">Edit</span> </a> </div> <h1>Basic Editing</h1> <p>Visual Studio Code is an editor first and foremost, and includes the features you need for highly productive source code editing. This topic takes you through the basics of the editor and helps you get moving with your code.</p> <h2 id="_keyboard-shortcuts" data-needslink="_keyboard-shortcuts">Keyboard shortcuts</h2> <p>Being able to keep your hands on the keyboard when writing code is crucial for high productivity. VS Code has a rich set of default keyboard shortcuts as well as allowing you to customize them.</p> <ul> <li><a href="/docs/getstarted/keybindings#_keyboard-shortcuts-reference">Keyboard Shortcuts Reference</a> - Learn the most commonly used and popular keyboard shortcuts by downloading the reference sheet.</li> <li><a href="/docs/getstarted/keybindings#_keymap-extensions">Install a Keymap extension</a> - Use the keyboard shortcuts of your old editor (such as Sublime Text, Atom, and Vim) in VS Code by installing a Keymap extension.</li> <li><a href="/docs/getstarted/keybindings#_keyboard-shortcuts-editor">Customize Keyboard Shortcuts</a> - Change the default keyboard shortcuts to fit your style.</li> </ul> <h2 id="_multiple-selections-multicursor" data-needslink="_multiple-selections-multicursor">Multiple selections (multi-cursor)</h2> <p>VS Code supports multiple cursors for fast simultaneous edits. You can add secondary cursors (rendered thinner) with <span class="keybinding">Alt+Click</span>. Each cursor operates independently based on the context it sits in. A common way to add more cursors is with <span class="dynamic-keybinding" data-commandId="editor.action.insertCursorBelow" data-osx="⌥⌘↓" data-win="Ctrl+Alt+Down" data-linux="Shift+Alt+Down"><span class="keybinding">⌥⌘↓</span> (Windows <span class="keybinding">Ctrl+Alt+Down</span>, Linux <span class="keybinding">Shift+Alt+Down</span>)</span> or <span class="dynamic-keybinding" data-commandId="editor.action.insertCursorAbove" data-osx="⌥⌘↑" data-win="Ctrl+Alt+Up" data-linux="Shift+Alt+Up"><span class="keybinding">⌥⌘↑</span> (Windows <span class="keybinding">Ctrl+Alt+Up</span>, Linux <span class="keybinding">Shift+Alt+Up</span>)</span> that insert cursors below or above.</p> <blockquote><p><strong>Note:</strong> Your graphics card driver (for example NVIDIA) might overwrite these default shortcuts.</p> </blockquote><p><img src="/assets/docs/editor/codebasics/multicursor.gif" alt="Multi-cursor" loading="lazy"></p> <p><span class="dynamic-keybinding" data-commandId="editor.action.addSelectionToNextFindMatch" data-osx="⌘D" data-win="Ctrl+D" data-linux="Ctrl+D"><span class="keybinding">⌘D</span> (Windows, Linux <span class="keybinding">Ctrl+D</span>)</span> selects the word at the cursor, or the next occurrence of the current selection.</p> <p><img src="/assets/docs/editor/codebasics/multicursor-word.gif" alt="Multi-cursor-next-word" loading="lazy"></p> <blockquote><p><strong>Tip:</strong> You can also add more cursors with <span class="dynamic-keybinding" data-commandId="editor.action.selectHighlights" data-osx="⇧⌘L" data-win="Ctrl+Shift+L" data-linux="Ctrl+Shift+L"><span class="keybinding">⇧⌘L</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+L</span>)</span>, which will add a selection at each occurrence of the current selected text.</p> </blockquote><h3 id="_multicursor-modifier" data-needslink="_multicursor-modifier">Multi-cursor modifier</h3> <p>If you'd like to change the modifier key for applying multiple cursors to <span class="keybinding">Cmd+Click</span> on macOS and <span class="keybinding">Ctrl+Click</span> on Windows and Linux, you can do so with the <span class="setting"><a href="vscode://settings/editor.multiCursorModifier" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.multiCursorModifier' in Settings Editor"></span></a>editor.multiCursorModifier</span> <a href="/docs/getstarted/settings">setting</a>. This lets users coming from other editors such as Sublime Text or Atom continue to use the keyboard modifier they are familiar with.</p> <p>The setting can be set to:</p> <ul> <li><code>ctrlCmd</code> - Maps to <span class="keybinding">Ctrl</span> on Windows and <span class="keybinding">Cmd</span> on macOS.</li> <li><code>alt</code> - The existing default <span class="keybinding">Alt</span>.</li> </ul> <p>There's also a menu item <strong>Selection</strong> > <strong>Switch to Ctrl+Click for Multi-Cursor</strong> or <strong>Selection</strong> > <strong>Switch to Alt+Click for Multi-Cursor</strong> to quickly toggle this setting.</p> <p>The <strong>Go to Definition</strong> and <strong>Open Link</strong> gestures will also respect this setting and adapt such that they do not conflict. For example, when the setting is <code>ctrlCmd</code>, multiple cursors can be added with <span class="keybinding">Ctrl/Cmd+Click</span>, and opening links or going to definition can be invoked with <span class="keybinding">Alt+Click</span>.</p> <h3 id="_shrinkexpand-selection" data-needslink="_shrinkexpand-selection">Shrink/expand selection</h3> <p>Quickly shrink or expand the current selection. Trigger it with <span class="dynamic-keybinding" data-commandId="editor.action.smartSelect.shrink" data-osx="⌃⇧⌘←" data-win="Shift+Alt+Left" data-linux="Shift+Alt+Left"><span class="keybinding">⌃⇧⌘←</span> (Windows, Linux <span class="keybinding">Shift+Alt+Left</span>)</span> and <span class="dynamic-keybinding" data-commandId="editor.action.smartSelect.expand" data-osx="⌃⇧⌘→" data-win="Shift+Alt+Right" data-linux="Shift+Alt+Right"><span class="keybinding">⌃⇧⌘→</span> (Windows, Linux <span class="keybinding">Shift+Alt+Right</span>)</span>.</p> <p>Here's an example of expanding the selection with <span class="dynamic-keybinding" data-commandId="editor.action.smartSelect.expand" data-osx="⌃⇧⌘→" data-win="Shift+Alt+Right" data-linux="Shift+Alt+Right"><span class="keybinding">⌃⇧⌘→</span> (Windows, Linux <span class="keybinding">Shift+Alt+Right</span>)</span>:</p> <p><img src="/assets/docs/editor/codebasics/expandselection.gif" alt="Expand selection" loading="lazy"></p> <h2 id="_column-box-selection" data-needslink="_column-box-selection">Column (box) selection</h2> <p>Place the cursor in one corner and then hold <span class="keybinding">Shift+Alt</span> while dragging to the opposite corner:</p> <p><img src="/assets/docs/editor/codebasics/column-select.gif" alt="Column text selection" loading="lazy"></p> <p>Note: This changes to <span class="keybinding">Shift+Ctrl/Cmd</span> when using <span class="keybinding">Ctrl/Cmd</span> as <a href="#_multi-cursor-modifier">multi-cursor modifier</a>.</p> <p>There are also default key bindings for column selection on macOS and Windows, but not on Linux.</p> <table class="table table-striped"> <thead> <tr> <th>Key</th> <th>Command</th> <th>Command ID</th> </tr> </thead> <tbody> <tr> <td><span class="dynamic-keybinding" data-commandId="cursorColumnSelectDown" data-osx="⇧↓" data-win="Shift+Down" data-linux="Shift+Down"><span class="keybinding">⇧↓</span> (Windows, Linux <span class="keybinding">Shift+Down</span>)</span></td> <td>Column Select Down</td> <td><code>cursorColumnSelectDown</code></td> </tr> <tr> <td><span class="dynamic-keybinding" data-commandId="cursorColumnSelectUp" data-osx="⇧↑" data-win="Shift+Up" data-linux="Shift+Up"><span class="keybinding">⇧↑</span> (Windows, Linux <span class="keybinding">Shift+Up</span>)</span></td> <td>Column Select Up</td> <td><code>cursorColumnSelectUp</code></td> </tr> <tr> <td><span class="dynamic-keybinding" data-commandId="cursorColumnSelectLeft" data-osx="⇧←" data-win="Shift+Left" data-linux="Shift+Left"><span class="keybinding">⇧←</span> (Windows, Linux <span class="keybinding">Shift+Left</span>)</span></td> <td>Column Select Left</td> <td><code>cursorColumnSelectLeft</code></td> </tr> <tr> <td><span class="dynamic-keybinding" data-commandId="cursorColumnSelectRight" data-osx="⇧→" data-win="Shift+Right" data-linux="Shift+Right"><span class="keybinding">⇧→</span> (Windows, Linux <span class="keybinding">Shift+Right</span>)</span></td> <td>Column Select Right</td> <td><code>cursorColumnSelectRight</code></td> </tr> <tr> <td><span class="dynamic-keybinding" data-commandId="cursorColumnSelectPageDown" data-osx="⇧PageDown" data-win="Shift+PageDown" data-linux="Shift+PageDown"><span class="keybinding">⇧PageDown</span> (Windows, Linux <span class="keybinding">Shift+PageDown</span>)</span></td> <td>Column Select Page Down</td> <td><code>cursorColumnSelectPageDown</code></td> </tr> <tr> <td><span class="dynamic-keybinding" data-commandId="cursorColumnSelectPageUp" data-osx="⇧PageUp" data-win="Shift+PageUp" data-linux="Shift+PageUp"><span class="keybinding">⇧PageUp</span> (Windows, Linux <span class="keybinding">Shift+PageUp</span>)</span></td> <td>Column Select Page Up</td> <td><code>cursorColumnSelectPageUp</code></td> </tr> </tbody> </table> <p>You can <a href="/docs/getstarted/keybindings">edit</a> your <code>keybindings.json</code> to bind them to something more familiar if you want.</p> <h3 id="_column-selection-mode" data-needslink="_column-selection-mode">Column Selection mode</h3> <p>The user setting <strong>Editor: Column Selection</strong> controls this feature. Once this mode is entered, as indicated in the Status bar, the mouse gestures and the arrow keys will create a column selection by default. This global toggle is also accessible via the <strong>Selection</strong> > <strong>Column Selection Mode</strong> menu item. In addition, one can also disable Column Selection mode from the Status bar.</p> <h2 id="_save-auto-save" data-needslink="_save-auto-save">Save / Auto Save</h2> <p>By default, VS Code requires an explicit action to save your changes to disk, <span class="dynamic-keybinding" data-commandId="workbench.action.files.save" data-osx="⌘S" data-win="Ctrl+S" data-linux="Ctrl+S"><span class="keybinding">⌘S</span> (Windows, Linux <span class="keybinding">Ctrl+S</span>)</span>.</p> <p>However, it's easy to turn on <code>Auto Save</code>, which will save your changes after a configured delay or when focus leaves the editor. With this option turned on, there is no need to explicitly save the file. The easiest way to turn on <code>Auto Save</code> is with the <strong>File</strong> > <strong>Auto Save</strong> toggle that turns on and off save after a delay.</p> <p>For more control over <code>Auto Save</code>, open User or Workspace <a href="/docs/getstarted/settings">settings</a> and find the associated settings:</p> <ul> <li><span class="setting"><a href="vscode://settings/files.autoSave" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.autoSave' in Settings Editor"></span></a>files.autoSave</span>: Can have the values: <ul> <li><code>off</code> - to disable auto save.</li> <li><code>afterDelay</code> - to save files after a configured delay (default 1000 ms).</li> <li><code>onFocusChange</code> - to save files when focus moves out of the editor of the dirty file.</li> <li><code>onWindowChange</code> - to save files when the focus moves out of the VS Code window.</li> </ul> </li> <li><span class="setting"><a href="vscode://settings/files.autoSaveDelay" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.autoSaveDelay' in Settings Editor"></span></a>files.autoSaveDelay</span>: Configures the delay in milliseconds when <span class="setting"><a href="vscode://settings/files.autoSave" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.autoSave' in Settings Editor"></span></a>files.autoSave</span> is configured to <code>afterDelay</code>. The default is 1000 ms.</li> </ul> <h2 id="_hot-exit" data-needslink="_hot-exit">Hot Exit</h2> <p>By default, VS Code remembers unsaved changes to files when you exit. Hot exit is triggered when the application is closed via <strong>File</strong> > <strong>Exit</strong> (<strong>Code</strong> > <strong>Quit</strong> on macOS) or when the last window is closed.</p> <p>You can configure hot exit by setting <span class="setting"><a href="vscode://settings/files.hotExit" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.hotExit' in Settings Editor"></span></a>files.hotExit</span> to the following values:</p> <ul> <li><code>"off"</code>: Disable hot exit.</li> <li><code>"onExit"</code>: Hot exit will be triggered when the application is closed, that is when the last window is closed on Windows/Linux or when the <code>workbench.action.quit</code> command is triggered (from the <strong>Command Palette</strong>, keyboard shortcut or menu). All windows without folders opened will be restored upon next launch.</li> <li><code>"onExitAndWindowClose"</code>: Hot exit will be triggered when the application is closed, that is when the last window is closed on Windows/Linux or when the <code>workbench.action.quit</code> command is triggered (from the <strong>Command Palette</strong>, keyboard shortcut or menu), and also for any window with a folder opened regardless of whether it is the last window. All windows without folders opened will be restored upon next launch. To restore folder windows as they were before shutdown, set <span class="setting"><a href="vscode://settings/window.restoreWindows" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'window.restoreWindows' in Settings Editor"></span></a>window.restoreWindows</span> to <code>all</code>.</li> </ul> <p>If something goes wrong with hot exit, all backups are stored in the following folders for standard install locations:</p> <ul> <li><strong>Windows</strong> <code>%APPDATA%\Code\Backups</code></li> <li><strong>macOS</strong> <code>$HOME/Library/Application Support/Code/Backups</code></li> <li><strong>Linux</strong> <code>$HOME/.config/Code/Backups</code></li> </ul> <h2 id="_find-and-replace" data-needslink="_find-and-replace">Find and Replace</h2> <p>VS Code allows you to quickly find text and replace in the currently opened file. Press <span class="dynamic-keybinding" data-commandId="actions.find" data-osx="⌘F" data-win="Ctrl+F" data-linux="Ctrl+F"><span class="keybinding">⌘F</span> (Windows, Linux <span class="keybinding">Ctrl+F</span>)</span> to open the Find Widget in the editor, search results will be highlighted in the editor, overview ruler and minimap.</p> <p>If there are more than one matched result in the current opened file, you can press <span class="dynamic-keybinding" data-commandId="editor.action.nextMatchFindAction" data-osx="Enter" data-win="Enter" data-linux="Enter"><span class="keybinding">Enter</span></span> and <span class="dynamic-keybinding" data-commandId="editor.action.previousMatchFindAction" data-osx="⇧Enter" data-win="Shift+Enter" data-linux="Shift+Enter"><span class="keybinding">⇧Enter</span> (Windows, Linux <span class="keybinding">Shift+Enter</span>)</span> to navigate to next or previous result when the find input box is focused.</p> <h3 id="_seed-search-string-from-selection" data-needslink="_seed-search-string-from-selection">Seed Search String From Selection</h3> <p>When the Find Widget is opened, it will automatically populate the selected text in the editor into the find input box. If the selection is empty, the word under the cursor will be inserted into the input box instead.</p> <p><img src="/assets/docs/editor/codebasics/seed-search-string-from-selection.gif" alt="Seed Search String From Selection" loading="lazy"></p> <p>This feature can be turned off by setting <span class="setting"><a href="vscode://settings/editor.find.seedSearchStringFromSelection" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.find.seedSearchStringFromSelection' in Settings Editor"></span></a>editor.find.seedSearchStringFromSelection</span> to <code>"never"</code>.</p> <h3 id="_find-in-selection" data-needslink="_find-in-selection">Find In Selection</h3> <p>By default, the find operations are run on the entire file in the editor. It can also be run on selected text. You can turn this feature on by clicking the hamburger icon on the Find Widget.</p> <p><img src="/assets/docs/editor/codebasics/find-in-selection.gif" alt="Find In Selection" loading="lazy"></p> <p>If you want it to be the default behavior of the Find Widget, you can set <span class="setting"><a href="vscode://settings/editor.find.autoFindInSelection" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.find.autoFindInSelection' in Settings Editor"></span></a>editor.find.autoFindInSelection</span> to <code>always</code>, or to <code>multiline</code>, if you want it to be run on selected text only when multiple lines of content are selected.</p> <h3 id="_advanced-find-and-replace-options" data-needslink="_advanced-find-and-replace-options">Advanced find and replace options</h3> <p>In addition to find and replace with plain text, the Find Widget also has three advanced search options:</p> <ul> <li>Match Case</li> <li>Match Whole Word</li> <li>Regular Expression</li> </ul> <p>The replace input box support case preserving, you can turn it on by clicking the Preserve Case (<strong>AB</strong>) button.</p> <h3 id="_multiline-support-and-find-widget-resizing" data-needslink="_multiline-support-and-find-widget-resizing">Multiline support and Find Widget resizing</h3> <p>You can search multiple line text by pasting the text into the Find input box and Replace input box. Pressing <code>Ctrl+Enter</code> inserts a new line in the input box.</p> <p><img src="/assets/docs/editor/codebasics/multiple-line-support.gif" alt="Multiple Line Support" loading="lazy"></p> <p>While searching long text, the default size of Find Widget might be too small. You can drag the left sash to enlarge the Find Widget or double click the left sash to maximize it or shrink it to its default size.</p> <p><img src="/assets/docs/editor/codebasics/resize-find-widget.gif" alt="Resize Find Widget" loading="lazy"></p> <h2 id="_search-across-files" data-needslink="_search-across-files">Search across files</h2> <p>VS Code allows you to quickly search over all files in the currently opened folder. Press <span class="dynamic-keybinding" data-commandId="workbench.view.search" data-osx="⇧⌘F" data-win="Ctrl+Shift+F" data-linux="Ctrl+Shift+F"><span class="keybinding">⇧⌘F</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+F</span>)</span> and enter your search term. Search results are grouped into files containing the search term, with an indication of the hits in each file and its location. Expand a file to see a preview of all of the hits within that file. Then single-click on one of the hits to view it in the editor.</p> <p><img src="/assets/docs/editor/codebasics/search.png" alt="A simple text search across files" loading="lazy"></p> <blockquote><p><strong>Tip:</strong> We support regular expression searching in the search box, too.</p> </blockquote><p>You can configure advanced search options by clicking the ellipsis (<strong>Toggle Search Details</strong>) below the search box on the right (or press <span class="dynamic-keybinding" data-commandId="workbench.action.search.toggleQueryDetails" data-osx="⇧⌘J" data-win="Ctrl+Shift+J" data-linux="Ctrl+Shift+J"><span class="keybinding">⇧⌘J</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+J</span>)</span>). This will show additional fields to configure the search.</p> <blockquote><p><strong>Tip:</strong> You can use Quick Search to quickly find text across all files in the currently opened folder. Open the Command Palette (<span class="dynamic-keybinding" data-commandId="workbench.action.showCommands" data-osx="⇧⌘P" data-win="Ctrl+Shift+P" data-linux="Ctrl+Shift+P"><span class="keybinding">⇧⌘P</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+P</span>)</span>) and enter the <strong>Search: Quick Search</strong> command.</p> </blockquote><h3 id="_advanced-search-options" data-needslink="_advanced-search-options">Advanced search options</h3> <p><img src="/assets/docs/editor/codebasics/searchadvanced.png" alt="Advanced search options" loading="lazy"></p> <p>In the two input boxes below the search box, you can enter patterns to include or exclude from the search. If you enter <code>example</code>, that will match every folder and file named <code>example</code> in the workspace. If you enter <code>./example</code>, that will match the folder <code>example/</code> at the top level of your workspace. Use <code>,</code> to separate multiple patterns. Paths must use forward slashes. You can also use <a href="/docs/editor/glob-patterns">glob pattern</a> syntax, for example:</p> <ul> <li><code>*</code> to match zero or more characters in a path segment</li> <li><code>?</code> to match on one character in a path segment</li> <li><code>**</code> to match any number of path segments, including none</li> <li><code>{}</code> to group conditions (for example <code>{**/*.html,**/*.txt}</code> matches all HTML and text files)</li> <li><code>[]</code> to <strong>declare</strong> a range of characters to match (<code>example.[0-9]</code> to match on <code>example.0</code>, <code>example.1</code>, …)</li> <li><code>[!...]</code> to negate a range of characters to match (<code>example.[!0-9]</code> to match on <code>example.a</code>, <code>example.b</code>, but not <code>example.0</code>)</li> </ul> <p>VS Code excludes some folders by default to reduce the number of search results that you are not interested in (for example: <code>node_modules</code>). Open <a href="/docs/getstarted/settings">settings</a> to change these rules under the <span class="setting"><a href="vscode://settings/files.exclude" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.exclude' in Settings Editor"></span></a>files.exclude</span> and <span class="setting"><a href="vscode://settings/search.exclude" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.exclude' in Settings Editor"></span></a>search.exclude</span> section.</p> <p>Note that glob patterns in the Search view work differently than in settings such as <span class="setting"><a href="vscode://settings/files.exclude" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.exclude' in Settings Editor"></span></a>files.exclude</span> and <span class="setting"><a href="vscode://settings/search.exclude" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.exclude' in Settings Editor"></span></a>search.exclude</span>. In the settings, you must use <code>**/example</code> to match a folder named <code>example</code> in subfolder <code>folder1/example</code> in your workspace. In the Search view, the <code>**</code> prefix is assumed. The glob patterns in these settings are always evaluated relative to the path of the workspace folder.</p> <p>Also note the <strong>Use Exclude Settings and Ignore Files</strong> toggle button in the <strong>files to exclude</strong> box. The toggle determines whether to exclude files that are ignored by your <code>.gitignore</code> files and/or matched by your <span class="setting"><a href="vscode://settings/files.exclude" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.exclude' in Settings Editor"></span></a>files.exclude</span> and <span class="setting"><a href="vscode://settings/search.exclude" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.exclude' in Settings Editor"></span></a>search.exclude</span> settings.</p> <blockquote><p><strong>Tip:</strong> From the Explorer, you can right-click on a folder and select <strong>Find in Folder</strong> to search inside a folder only.</p> </blockquote><h3 id="_search-and-replace" data-needslink="_search-and-replace">Search and replace</h3> <p>You can also Search and Replace across files. Expand the Search widget to display the Replace text box.</p> <p><img src="/assets/docs/editor/codebasics/global-search-replace.png" alt="search and replace" loading="lazy"></p> <p>When you type text into the Replace text box, you will see a diff display of the pending changes. You can replace across all files from the Replace text box, replace all in one file or replace a single change.</p> <p><img src="/assets/docs/editor/codebasics/search-replace-example.png" alt="search and replace diff view" loading="lazy"></p> <blockquote><p><strong>Tip:</strong> You can quickly reuse a previous search term by using <span class="dynamic-keybinding" data-commandId="history.showNext" data-osx="↓" data-win="Down" data-linux="Down"><span class="keybinding">↓</span> (Windows, Linux <span class="keybinding">Down</span>)</span> and <span class="dynamic-keybinding" data-commandId="history.showPrevious" data-osx="↑" data-win="Up" data-linux="Up"><span class="keybinding">↑</span> (Windows, Linux <span class="keybinding">Up</span>)</span> to navigate through your search term history.</p> </blockquote><h3 id="_case-changing-in-regex-replace" data-needslink="_case-changing-in-regex-replace">Case changing in regex replace</h3> <p>VS Code supports changing the case of regex matching groups while doing Search and Replace in the editor or globally. This is done with the modifiers <code>\u\U\l\L</code>, where <code>\u</code> and <code>\l</code> will upper/lowercase a single character, and <code>\U</code> and <code>\L</code> will upper/lowercase the rest of the matching group.</p> <p>Example:</p> <p><img src="/assets/docs/editor/codebasics/case-change-replace.gif" alt="Changing case while doing find and replace" loading="lazy"></p> <p>The modifiers can also be stacked - for example, <code>\u\u\u$1</code> will uppercase the first three characters of the group, or <code>\l\U$1</code> will lowercase the first character, and uppercase the rest. The capture group is referenced by <code>$n</code> in the replacement string, where <code>n</code> is the order of the capture group.</p> <h2 id="_search-editor" data-needslink="_search-editor">Search Editor</h2> <p>Search Editors let you view workspace search results in a full-sized editor, complete with syntax highlighting and optional lines of surrounding context.</p> <p>Below is a search for the word 'SearchEditor' with two lines of text before and after the match for context:</p> <p><img src="/assets/docs/editor/codebasics/search-editor-overview.png" alt="Search Editor overview" loading="lazy"></p> <p>The <strong>Open Search Editor</strong> command opens an existing Search Editor if one exists, or to otherwise create a new one. The <strong>New Search Editor</strong> command will always create a new Search Editor.</p> <p>In the Search Editor, results can be navigated to using <strong>Go to Definition</strong> actions, such as <span class="dynamic-keybinding" data-commandId="editor.action.revealDefinition" data-osx="F12" data-win="F12" data-linux="F12"><span class="keybinding">F12</span></span> to open the source location in the current editor group, or <span class="dynamic-keybinding" data-commandId="editor.action.revealDefinitionAside" data-osx="⌘K F12" data-win="Ctrl+K F12" data-linux="Ctrl+K F12"><span class="keybinding">⌘K F12</span> (Windows, Linux <span class="keybinding">Ctrl+K F12</span>)</span> to open the location in an editor to the side. Additionally, you can configure the behavior for single-clicking or double-clicking a search result with the <span class="setting"><a href="vscode://settings/search.searchEditor.singleClickBehaviour" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.searchEditor.singleClickBehaviour' in Settings Editor"></span></a>search.searchEditor.singleClickBehaviour</span> and <span class="setting"><a href="vscode://settings/search.searchEditor.doubleClickBehaviour" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.searchEditor.doubleClickBehaviour' in Settings Editor"></span></a>search.searchEditor.doubleClickBehaviour</span> settings. For example, to open a peek definition window or to open the source location.</p> <p>You can also use the <strong>Open New Search Editor</strong> button at the top of the Search view, and can copy your existing results from a Search view over to a Search Editor with the <strong>Open in editor</strong> link at the top of the results tree, or the <strong>Search Editor: Open Results in Editor</strong> command.</p> <p><img src="/assets/docs/editor/codebasics/search-editor-button.png" alt="Search Editor Button" loading="lazy"></p> <p>The Search Editor above was opened by selecting the <strong>Open New Search Editor</strong> button (third button) on the top of the Search view.</p> <h3 id="_search-editor-commands-and-arguments" data-needslink="_search-editor-commands-and-arguments">Search Editor commands and arguments</h3> <ul> <li><code>search.action.openNewEditor</code> - Opens the Search Editor in a new tab.</li> <li><code>search.action.openInEditor</code> - Copy the current Search results into a new Search Editor.</li> <li><code>search.action.openNewEditorToSide</code> - Opens the Search Editor in a new window next to the window you currently have opened.</li> </ul> <p>There are two arguments that you can pass to the Search Editor commands (<code>search.action.openNewEditor</code>, <code>search.action.openNewEditorToSide</code>) to allow keybindings to configure how a new Search Editor should behave:</p> <ul> <li><code>triggerSearch</code> - Whether a search be automatically run when a Search Editor is opened. Default is true.</li> <li><code>focusResults</code> - Whether to put focus in the results of a search or the query input. Default is true.</li> </ul> <p>For example, the following keybinding runs the search when the Search Editor is opened but leaves the focus in the search query control.</p> <pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #BBBBBB">{</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"key"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"ctrl+o"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"command"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"search.action.openNewEditor"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"args"</span><span style="color: #BBBBBB">: { </span><span style="color: #9CDCFE">"query"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"VS Code"</span><span style="color: #BBBBBB">, </span><span style="color: #9CDCFE">"triggerSearch"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">true</span><span style="color: #BBBBBB">, </span><span style="color: #9CDCFE">"focusResults"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">false</span><span style="color: #BBBBBB"> }</span></span> <span class="line"><span style="color: #BBBBBB">}</span></span> <span class="line"></span></code></pre> <h3 id="_search-editor-context-default" data-needslink="_search-editor-context-default">Search Editor context default</h3> <p>The <span class="setting"><a href="vscode://settings/search.searchEditor.defaultNumberOfContextLines" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.searchEditor.defaultNumberOfContextLines' in Settings Editor"></span></a>search.searchEditor.defaultNumberOfContextLines</span> setting has a default value of 1, meaning one context line will be shown before and after each result line in the Search Editor.</p> <h3 id="_reuse-last-search-editor-configuration" data-needslink="_reuse-last-search-editor-configuration">Reuse last Search Editor configuration</h3> <p>The <span class="setting"><a href="vscode://settings/search.searchEditor.reusePriorSearchConfiguration" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'search.searchEditor.reusePriorSearchConfiguration' in Settings Editor"></span></a>search.searchEditor.reusePriorSearchConfiguration</span> setting (default is <code>false</code>) lets you reuse the last active Search Editor's configuration when creating a new Search Editor.</p> <h2 id="_intellisense" data-needslink="_intellisense">IntelliSense</h2> <p>We'll always offer word completion, but for the rich <a href="/docs/languages/overview">languages</a>, such as JavaScript, JSON, HTML, CSS, SCSS, Less, C# and TypeScript, we offer a true IntelliSense experience. If a language service knows possible completions, the IntelliSense suggestions will pop up as you type. You can always manually trigger it with <span class="dynamic-keybinding" data-commandId="editor.action.triggerSuggest" data-osx="⌃Space" data-win="Ctrl+Space" data-linux="Ctrl+Space"><span class="keybinding">⌃Space</span> (Windows, Linux <span class="keybinding">Ctrl+Space</span>)</span>. By default, <span class="keybinding">Tab</span> or <span class="keybinding">Enter</span> are the accept keyboard triggers but you can also <a href="/docs/getstarted/keybindings">customize these key bindings</a>.</p> <blockquote><p><strong>Tip:</strong> The suggestions filtering supports CamelCase, so you can type the letters which are upper cased in a method name to limit the suggestions. For example, "cra" will quickly bring up "createApplication".</p> </blockquote><blockquote><p><strong>Tip:</strong> IntelliSense suggestions can be configured via the <span class="setting"><a href="vscode://settings/editor.quickSuggestions" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.quickSuggestions' in Settings Editor"></span></a>editor.quickSuggestions</span> and <span class="setting"><a href="vscode://settings/editor.suggestOnTriggerCharacters" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.suggestOnTriggerCharacters' in Settings Editor"></span></a>editor.suggestOnTriggerCharacters</span> <a href="/docs/getstarted/settings">settings</a>.</p> </blockquote><p>JavaScript and TypeScript developers can take advantage of the <a href="https://www.npmjs.com" class="external-link" target="_blank">npmjs</a> type declaration (typings) file repository to get IntelliSense for common JavaScript libraries (Node.js, React, Angular). You can find a good explanation on using type declaration files in the <a href="/docs/languages/javascript#_intellisense">JavaScript language</a> topic and the <a href="/docs/nodejs/nodejs-tutorial">Node.js</a> tutorial.</p> <p>Learn more in the <a href="/docs/editor/intellisense">IntelliSense document</a>.</p> <h2 id="_formatting" data-needslink="_formatting">Formatting</h2> <p>VS Code has great support for source code formatting. The editor has two explicit format actions:</p> <ul> <li><strong>Format Document</strong> (<span class="dynamic-keybinding" data-commandId="editor.action.formatDocument" data-osx="⇧⌥F" data-win="Shift+Alt+F" data-linux="Ctrl+Shift+I"><span class="keybinding">⇧⌥F</span> (Windows <span class="keybinding">Shift+Alt+F</span>, Linux <span class="keybinding">Ctrl+Shift+I</span>)</span>) - Format the entire active file.</li> <li><strong>Format Selection</strong> (<span class="dynamic-keybinding" data-commandId="editor.action.formatSelection" data-osx="⌘K ⌘F" data-win="Ctrl+K Ctrl+F" data-linux="Ctrl+K Ctrl+F"><span class="keybinding">⌘K ⌘F</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+F</span>)</span>) - Format the selected text.</li> </ul> <p>You can invoke these from the <strong>Command Palette</strong> (<span class="dynamic-keybinding" data-commandId="workbench.action.showCommands" data-osx="⇧⌘P" data-win="Ctrl+Shift+P" data-linux="Ctrl+Shift+P"><span class="keybinding">⇧⌘P</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+P</span>)</span>) or the editor context menu.</p> <p>VS Code has default formatters for JavaScript, TypeScript, JSON, HTML, and CSS. Each language has specific formatting options (for example, <span class="setting"><a href="vscode://settings/html.format.indentInnerHtml" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'html.format.indentInnerHtml' in Settings Editor"></span></a>html.format.indentInnerHtml</span>) which you can tune to your preference in your user or workspace <a href="/docs/getstarted/settings">settings</a>. You can also disable the default language formatter if you have another extension installed that provides formatting for the same language.</p> <pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #CE9178">"html.format.enable"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">false</span></span> <span class="line"></span></code></pre> <p>Along with manually invoking code formatting, you can also trigger formatting based on user gestures such as typing, saving or pasting. These are off by default but you can enable these behaviors through the following <a href="/docs/getstarted/settings">settings</a>:</p> <ul> <li><span class="setting"><a href="vscode://settings/editor.formatOnType" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.formatOnType' in Settings Editor"></span></a>editor.formatOnType</span> - Format the line after typing.</li> <li><span class="setting"><a href="vscode://settings/editor.formatOnSave" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.formatOnSave' in Settings Editor"></span></a>editor.formatOnSave</span> - Format a file on save.</li> <li><span class="setting"><a href="vscode://settings/editor.formatOnPaste" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.formatOnPaste' in Settings Editor"></span></a>editor.formatOnPaste</span> - Format the pasted content.</li> </ul> <blockquote><p>Note: Not all formatters support format on paste as to do so they must support formatting a selection or range of text.</p> </blockquote><p>In addition to the default formatters, you can find extensions on the Marketplace to support other languages or formatting tools. There is a <code>Formatters</code> category so you can easily search and find <a href="https://marketplace.visualstudio.com/search?target=VSCode&category=Formatters&sortBy=Installs" class="external-link" target="_blank">formatting extensions</a>. In the <strong>Extensions</strong> view search box, type 'formatters' or 'category:formatters' to see a filtered list of extensions within VS Code.</p> <h2 id="_folding" data-needslink="_folding">Folding</h2> <p>You can fold regions of source code using the folding icons on the gutter between line numbers and line start. Move the mouse over the gutter and click to fold and unfold regions. Use <span class="keybinding">Shift + Click</span> on the folding icon to fold or unfold the region and all regions inside.</p> <p><img src="/assets/docs/editor/codebasics/folding.png" alt="Folding" loading="lazy"></p> <p>You can also use the following actions:</p> <ul> <li>Fold (<span class="dynamic-keybinding" data-commandId="editor.fold" data-osx="⌥⌘[" data-win="Ctrl+Shift+[" data-linux="Ctrl+Shift+["><span class="keybinding">⌥⌘[</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+[</span>)</span>) folds the innermost uncollapsed region at the cursor.</li> <li>Unfold (<span class="dynamic-keybinding" data-commandId="editor.unfold" data-osx="⌥⌘]" data-win="Ctrl+Shift+]" data-linux="Ctrl+Shift+]"><span class="keybinding">⌥⌘]</span> (Windows, Linux <span class="keybinding">Ctrl+Shift+]</span>)</span>) unfolds the collapsed region at the cursor.</li> <li>Toggle Fold (<span class="dynamic-keybinding" data-commandId="editor.toggleFold" data-osx="⌘K ⌘L" data-win="Ctrl+K Ctrl+L" data-linux="Ctrl+K Ctrl+L"><span class="keybinding">⌘K ⌘L</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+L</span>)</span>) folds or unfolds the region at the cursor.</li> <li>Fold Recursively (<span class="dynamic-keybinding" data-commandId="editor.foldRecursively" data-osx="⌘K ⌘[" data-win="Ctrl+K Ctrl+[" data-linux="Ctrl+K Ctrl+["><span class="keybinding">⌘K ⌘[</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+[</span>)</span>) folds the innermost uncollapsed region at the cursor and all regions inside that region.</li> <li>Unfold Recursively (<span class="dynamic-keybinding" data-commandId="editor.unfoldRecursively" data-osx="⌘K ⌘]" data-win="Ctrl+K Ctrl+]" data-linux="Ctrl+K Ctrl+]"><span class="keybinding">⌘K ⌘]</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+]</span>)</span>) unfolds the region at the cursor and all regions inside that region.</li> <li>Fold All (<span class="dynamic-keybinding" data-commandId="editor.foldAll" data-osx="⌘K ⌘0" data-win="Ctrl+K Ctrl+0" data-linux="Ctrl+K Ctrl+0"><span class="keybinding">⌘K ⌘0</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+0</span>)</span>) folds all regions in the editor.</li> <li>Unfold All (<span class="dynamic-keybinding" data-commandId="editor.unfoldAll" data-osx="⌘K ⌘J" data-win="Ctrl+K Ctrl+J" data-linux="Ctrl+K Ctrl+J"><span class="keybinding">⌘K ⌘J</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+J</span>)</span>) unfolds all regions in the editor.</li> <li>Fold Level X (<span class="dynamic-keybinding" data-commandId="editor.foldLevel2" data-osx="⌘K ⌘2" data-win="Ctrl+K Ctrl+2" data-linux="Ctrl+K Ctrl+2"><span class="keybinding">⌘K ⌘2</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+2</span>)</span> for level 2) folds all regions of level X, except the region at the current cursor position.</li> <li>Fold All Block Comments (<span class="dynamic-keybinding" data-commandId="editor.foldAllBlockComments" data-osx="⌘K ⌘/" data-win="Ctrl+K Ctrl+/" data-linux="Ctrl+K Ctrl+/"><span class="keybinding">⌘K ⌘/</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+/</span>)</span>) folds all regions that start with a block comment token.</li> </ul> <p>Folding regions are by default evaluated based on the indentation of lines. A folding region starts when a line has a smaller indent than one or more following lines, and ends when there is a line with the same or smaller indent.</p> <p>Folding regions can also be computed based on syntax tokens of the editor's configured language. The following languages already provide syntax aware folding: Markdown, HTML, CSS, LESS, SCSS, and JSON.</p> <p>If you prefer to switch back to indentation-based folding for one (or all) of the languages above, use:</p> <pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #BBBBBB"> </span><span style="color: #CE9178">"[html]"</span><span style="color: #BBBBBB">: {</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"editor.foldingStrategy"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"indentation"</span></span> <span class="line"><span style="color: #BBBBBB"> },</span></span> <span class="line"></span></code></pre> <p>Regions can also be defined by markers defined by each language. The following languages currently have markers defined:</p> <table class="table table-striped"> <thead> <tr> <th>Language</th> <th>Start region</th> <th>End region</th> </tr> </thead> <tbody> <tr> <td>Bat</td> <td><code>::#region</code> or <code>REM #region</code></td> <td><code>::#endregion</code> or <code>REM #endregion</code></td> </tr> <tr> <td>C#</td> <td><code>#region</code></td> <td><code>#endregion</code></td> </tr> <tr> <td>C/C++</td> <td><code>#pragma region</code></td> <td><code>#pragma endregion</code></td> </tr> <tr> <td>CSS/Less/SCSS</td> <td><code>/*#region*/</code></td> <td><code>/*#endregion*/</code></td> </tr> <tr> <td>Coffeescript</td> <td><code>#region</code></td> <td><code>#endregion</code></td> </tr> <tr> <td>F#</td> <td><code>//#region</code> or <code>(#_region)</code></td> <td><code>//#endregion</code> or <code>(#_endregion)</code></td> </tr> <tr> <td>Java</td> <td><code>//#region</code> or <code>//<editor-fold></code></td> <td><code>//#endregion</code> or <code>//</editor-fold></code></td> </tr> <tr> <td>Markdown</td> <td><code><!-- #region --></code></td> <td><code><!-- #endregion --></code></td> </tr> <tr> <td>Perl5</td> <td><code>#region</code> or <code>=pod</code></td> <td><code>#endregion</code> or <code>=cut</code></td> </tr> <tr> <td>PHP</td> <td><code>#region</code></td> <td><code>#endregion</code></td> </tr> <tr> <td>PowerShell</td> <td><code>#region</code></td> <td><code>#endregion</code></td> </tr> <tr> <td>Python</td> <td><code>#region</code> or <code># region</code></td> <td><code>#endregion</code> or <code># endregion</code></td> </tr> <tr> <td>TypeScript/JavaScript</td> <td><code>//#region</code></td> <td><code>//#endregion</code></td> </tr> <tr> <td>Visual Basic</td> <td><code>#Region</code></td> <td><code>#End Region</code></td> </tr> </tbody> </table> <p>To fold and unfold only the regions defined by markers use:</p> <ul> <li>Fold Marker Regions (<span class="dynamic-keybinding" data-commandId="editor.foldAllMarkerRegions" data-osx="⌘K ⌘8" data-win="Ctrl+K Ctrl+8" data-linux="Ctrl+K Ctrl+8"><span class="keybinding">⌘K ⌘8</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+8</span>)</span>) folds all marker regions.</li> <li>Unfold Marker Regions (<span class="dynamic-keybinding" data-commandId="editor.unfoldAllMarkerRegions" data-osx="⌘K ⌘9" data-win="Ctrl+K Ctrl+9" data-linux="Ctrl+K Ctrl+9"><span class="keybinding">⌘K ⌘9</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+9</span>)</span>) unfolds all marker regions.</li> </ul> <h3 id="_fold-selection" data-needslink="_fold-selection">Fold selection</h3> <p>The command <strong>Create Manual Folding Ranges from Selection</strong> (<span class="dynamic-keybinding" data-commandId="editor.createFoldingRangeFromSelection" data-osx="⌘K ⌘," data-win="Ctrl+K Ctrl+," data-linux="Ctrl+K Ctrl+,"><span class="keybinding">⌘K ⌘,</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+,</span>)</span>) creates a folding range from the currently selected lines and collapses it. That range is called a <strong>manual</strong> folding range that goes on top of the ranges computed by folding providers.</p> <p>Manual folding ranges can be removed with the command <strong>Remove Manual Folding Ranges</strong> (<span class="dynamic-keybinding" data-commandId="editor.removeManualFoldingRanges" data-osx="⌘K ⌘." data-win="Ctrl+K Ctrl+." data-linux="Ctrl+K Ctrl+."><span class="keybinding">⌘K ⌘.</span> (Windows, Linux <span class="keybinding">Ctrl+K Ctrl+.</span>)</span>).</p> <p>Manual folding ranges are especially useful for cases when there isn't programming language support for folding.</p> <h2 id="_indentation" data-needslink="_indentation">Indentation</h2> <p>VS Code lets you control text indentation and whether you'd like to use spaces or tab stops. By default, VS Code inserts spaces and uses 4 spaces per <span class="keybinding">Tab</span> key. If you'd like to use another default, you can modify the <span class="setting"><a href="vscode://settings/editor.insertSpaces" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.insertSpaces' in Settings Editor"></span></a>editor.insertSpaces</span> and <span class="setting"><a href="vscode://settings/editor.tabSize" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.tabSize' in Settings Editor"></span></a>editor.tabSize</span> <a href="/docs/getstarted/settings">settings</a>.</p> <pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #BBBBBB"> </span><span style="color: #CE9178">"editor.insertSpaces"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">true</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #CE9178">"editor.tabSize"</span><span style="color: #BBBBBB">: </span><span style="color: #B5CEA8">4</span><span style="color: #BBBBBB">,</span></span> <span class="line"></span></code></pre> <h3 id="_autodetection" data-needslink="_autodetection">Auto-detection</h3> <p>VS Code analyzes your open file and determines the indentation used in the document. The auto-detected indentation overrides your default indentation settings. The detected setting is displayed on the right side of the Status Bar:</p> <p><img src="/assets/docs/editor/codebasics/indentation-detection.png" alt="auto detect indentation" loading="lazy"></p> <p>You can click on the Status Bar indentation display to bring up a dropdown with indentation commands allowing you to change the default settings for the open file or convert between tab stops and spaces.</p> <p><img src="/assets/docs/editor/codebasics/indentation-commands.png" alt="indentation commands" loading="lazy"></p> <blockquote><p><strong>Note:</strong> VS Code auto-detection checks for indentations of 2, 4, 6 or 8 spaces. If your file uses a different number of spaces, the indentation may not be correctly detected. For example, if your convention is to indent with 3 spaces, you may want to turn off <span class="setting"><a href="vscode://settings/editor.detectIndentation" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.detectIndentation' in Settings Editor"></span></a>editor.detectIndentation</span> and explicitly set the tab size to 3.</p> </blockquote><pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #BBBBBB"> </span><span style="color: #CE9178">"editor.detectIndentation"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">false</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #CE9178">"editor.tabSize"</span><span style="color: #BBBBBB">: </span><span style="color: #B5CEA8">3</span><span style="color: #BBBBBB">,</span></span> <span class="line"></span></code></pre> <h2 id="_file-encoding-support" data-needslink="_file-encoding-support">File encoding support</h2> <p>Set the file encoding globally or per workspace by using the <span class="setting"><a href="vscode://settings/files.encoding" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'files.encoding' in Settings Editor"></span></a>files.encoding</span> setting in <strong>User Settings</strong> or <strong>Workspace Settings</strong>.</p> <p><img src="/assets/docs/editor/codebasics/filesencodingsetting.png" alt="files.encoding setting" loading="lazy"></p> <p>You can view the file encoding in the status bar.</p> <p><img src="/assets/docs/editor/codebasics/fileencoding.png" alt="Encoding in status bar" loading="lazy"></p> <p>Click on the encoding button in the status bar to reopen or save the active file with a different encoding.</p> <p><img src="/assets/docs/editor/codebasics/encodingclicked.png" alt="Reopen or save with a different encoding" loading="lazy"></p> <p>Then choose an encoding.</p> <p><img src="/assets/docs/editor/codebasics/encodingselection.png" alt="Select an encoding" loading="lazy"></p> <h2 id="_compare-files" data-needslink="_compare-files">Compare files</h2> <p>VS Code supports several ways to compare the content of the current file or of any two files.</p> <p>When you have an active file open in the editor, you have the following compare options:</p> <ul> <li><strong>Compare with a workspace file</strong>: in the Command Palette, select <strong>File: Compare Active File With...</strong>, and then choose another file to compare with.</li> <li><strong>Compare with clipboard</strong>: in the Command Palette, select <strong>File: Compare Active File with Clipboard</strong> (<span class="dynamic-keybinding" data-commandId="workbench.files.action.compareWithClipboard" data-osx="⌘K C" data-win="Ctrl+K C" data-linux="Ctrl+K C"><span class="keybinding">⌘K C</span> (Windows, Linux <span class="keybinding">Ctrl+K C</span>)</span>) to compare the current file with the clipboard content.</li> <li><strong>Compare with saved</strong>: in the Command Palette, select <strong>File: Compare Active File with Saved</strong> (<span class="dynamic-keybinding" data-commandId="workbench.files.action.compareWithSaved" data-osx="⌘K D" data-win="Ctrl+K D" data-linux="Ctrl+K D"><span class="keybinding">⌘K D</span> (Windows, Linux <span class="keybinding">Ctrl+K D</span>)</span>) to compare the current file with the last saved version.</li> </ul> <p>To compare any two files:</p> <ul> <li>Right-click on a file in the Explorer view and select <strong>Select for Compare</strong>. Then, right-click on a second file and select <strong>Compare with Selected</strong>.</li> <li>To start a comparison between two empty editor windows, select <strong>File: Compare New Untitled Text Files</strong> from the Command Palette.</li> </ul> <blockquote><p><strong>Tip:</strong> You can start VS Code from the command line with the <code>--diff</code> option to compare two files. Learn more about the <a href="/docs/editor/command-line#_core-cli-options">VS Code command line interface</a>.</p> </blockquote><h2 id="_next-steps" data-needslink="_next-steps">Next steps</h2> <p>You've covered the basic user interface - there is a lot more to VS Code. Read on to find out about:</p> <ul> <li><a href="/docs/introvideos/basics">Intro Video - Setup and Basics</a> - Watch a tutorial on the basics of VS Code.</li> <li><a href="/docs/getstarted/settings">User/Workspace Settings</a> - Learn how to configure VS Code to your preferences through user and workspace settings.</li> <li><a href="/docs/editor/editingevolved">Code Navigation</a> - Peek and Goto Definition, and more.</li> <li><a href="/docs/terminal/basics">Integrated Terminal</a> - Learn about the integrated terminal for quickly performing command-line tasks from within VS Code.</li> <li><a href="/docs/editor/intellisense">IntelliSense</a> - VS Code brings smart code completions.</li> <li><a href="/docs/editor/debugging">Debugging</a> - This is where VS Code really shines.</li> </ul> <h2 id="_common-questions" data-needslink="_common-questions">Common questions</h2> <h3 id="_is-it-possible-to-globally-search-and-replace" data-needslink="_is-it-possible-to-globally-search-and-replace">Is it possible to globally search and replace?</h3> <p>Yes, expand the Search view text box to include a replace text field. You can search and replace across all the files in your workspace. Note that if you did not open VS Code on a folder, the search will only run on the currently open files.</p> <p><img src="/assets/docs/editor/codebasics/global-search-replace.png" alt="global search and replace" loading="lazy"></p> <h3 id="_how-do-i-turn-on-word-wrap" data-needslink="_how-do-i-turn-on-word-wrap">How do I turn on word wrap?</h3> <p>You can control word wrap through the <span class="setting"><a href="vscode://settings/editor.wordWrap" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.wordWrap' in Settings Editor"></span></a>editor.wordWrap</span> <a href="/docs/getstarted/settings">setting</a>. By default, <span class="setting"><a href="vscode://settings/editor.wordWrap" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.wordWrap' in Settings Editor"></span></a>editor.wordWrap</span> is <code>off</code> but if you set to it to <code>on</code>, text will wrap on the editor's viewport width.</p> <pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #BBBBBB"> </span><span style="color: #CE9178">"editor.wordWrap"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"on"</span></span> <span class="line"></span></code></pre> <p>You can toggle word wrap for the VS Code session with <span class="dynamic-keybinding" data-commandId="editor.action.toggleWordWrap" data-osx="⌥Z" data-win="Alt+Z" data-linux="Alt+Z"><span class="keybinding">⌥Z</span> (Windows, Linux <span class="keybinding">Alt+Z</span>)</span>.</p> <p>You can also add vertical column rulers to the editor with the <span class="setting"><a href="vscode://settings/editor.rulers" codesetting="true"><span class="codicon codicon-settings-gear dynamic-setting-icon" title="Open 'editor.rulers' in Settings Editor"></span></a>editor.rulers</span> setting, which takes an array of column character positions where you'd like vertical rulers.</p> <p>As in other editors, commands such as <strong>Cut</strong> and <strong>Copy</strong> apply to the whole wrapped line. Triple-click selects the whole wrapped line. Pressing <span class="keybinding">Home</span> twice moves the cursor to the very beginning of the line. Pressing <span class="keybinding">End</span> twice moves the cursor to the very end of the line.</p> <h3 id="_how-can-i-avoid-placing-extra-cursors-in-word-wrapped-lines" data-needslink="_how-can-i-avoid-placing-extra-cursors-in-word-wrapped-lines">How can I avoid placing extra cursors in word wrapped lines?</h3> <p>If you'd like to ignore line wraps when adding cursors above or below your current selection, you can pass in <code>{ "logicalLine": true }</code> to <code>args</code> on the keybinding like this:</p> <pre class="shiki" style="background-color: #1e1e1e"><code><span class="line"><span style="color: #BBBBBB">{</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"key"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"shift+alt+down"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"command"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"editor.action.insertCursorBelow"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"when"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"textInputFocus"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"args"</span><span style="color: #BBBBBB">: { </span><span style="color: #9CDCFE">"logicalLine"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">true</span><span style="color: #BBBBBB"> },</span></span> <span class="line"><span style="color: #BBBBBB">},</span></span> <span class="line"><span style="color: #BBBBBB">{</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"key"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"shift+alt+up"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"command"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"editor.action.insertCursorAbove"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"when"</span><span style="color: #BBBBBB">: </span><span style="color: #CE9178">"textInputFocus"</span><span style="color: #BBBBBB">,</span></span> <span class="line"><span style="color: #BBBBBB"> </span><span style="color: #9CDCFE">"args"</span><span style="color: #BBBBBB">: { </span><span style="color: #9CDCFE">"logicalLine"</span><span style="color: #BBBBBB">: </span><span style="color: #569CD6">true</span><span style="color: #BBBBBB"> },</span></span> <span class="line"><span style="color: #BBBBBB">},</span></span> <span class="line"></span></code></pre> <div class="feedback"></div> <div class="body-footer">10/29/2024</div> </main> <!-- medium right nav --> <div class="col-sm-3 col-md-2 hidden-xs docs-subnavbar-container"> <nav id="docs-subnavbar" aria-label="On Page" data-spy="affix" data-offset-top="20"> <h4><span class="sr-only">In this article there are 16 sections</span><span aria-hidden="true">In this article</span></h4> <ul class="nav"> <li><a href="#_keyboard-shortcuts">Keyboard shortcuts</a></li> <li><a href="#_multiple-selections-multicursor">Multiple selections (multi-cursor)</a></li> <li><a href="#_column-box-selection">Column (box) selection</a></li> <li><a href="#_save-auto-save">Save / Auto Save</a></li> <li><a href="#_hot-exit">Hot Exit</a></li> <li><a href="#_find-and-replace">Find and Replace</a></li> <li><a href="#_search-across-files">Search across files</a></li> <li><a href="#_search-editor">Search Editor</a></li> <li><a href="#_intellisense">IntelliSense</a></li> <li><a href="#_formatting">Formatting</a></li> <li><a href="#_folding">Folding</a></li> <li><a href="#_indentation">Indentation</a></li> <li><a href="#_file-encoding-support">File encoding support</a></li> <li><a href="#_compare-files">Compare files</a></li> <li><a href="#_next-steps">Next steps</a></li> <li><a href="#_common-questions">Common questions</a></li> </ul> <div class="connect-widget"></div> </nav> </div> <!-- end of page connect widget --> <div class="col-xs-12 visible-xs"> <div class="connect-widget"></div> </div> </div> </div> </div> </div> <footer role="contentinfo" class="container"> <div class="footer-container"> <div class="footer-row"> <div class="footer-social"> <ul class="links"> <li> <a href="https://go.microsoft.com/fwlink/?LinkID=533687"><img src="/assets/icons/x-icon.svg" class="x-icon" alt="Follow us on X"></a> </li> <li> <a href="https://github.com/microsoft/vscode"><img src="/assets/icons/github-icon.svg" alt="VS Code on Github"></a> </li> <li> <a href="https://www.youtube.com/@code"><img src="/assets/icons/youtube-icon.svg" alt="VS Code on YouTube"></a> </li> <script> function manageConsent() { if (siteConsent && siteConsent.isConsentRequired) { siteConsent.manageConsent(); } } </script> </ul> <a id="footer-microsoft-link" class="microsoft-logo" href="https://www.microsoft.com"> <img src="/assets/icons/microsoft.svg" alt="Microsoft homepage" /> </a> </div> </div> <div class="footer-row"> <ul class="links"> <li><a id="footer-support-link" href="https://support.serviceshub.microsoft.com/supportforbusiness/create?sapId=d66407ed-3967-b000-4cfb-2c318cad363d" target="_blank" rel="noopener">Support</a></li> <li><a id="footer-privacy-link" href="https://go.microsoft.com/fwlink/?LinkId=521839" target="_blank" rel="noopener">Privacy</a></li> <li style="display: none;"><a id="footer-cookie-link" style="cursor: pointer;" onclick="manageConsent()" target="_blank" rel="noopener">Manage Cookies</a></li> <li><a id="footer-terms-link" href="https://www.microsoft.com/legal/terms-of-use" target="_blank" rel="noopener">Terms of Use</a></li> <li><a id="footer-license-link" href="/License" target="_blank" rel="noopener">License</a></li> </ul> </div> </div> </footer> <script src="/dist/index.js"></script> <script type="application/ld+json"> { "@context" : "http://schema.org", "@type" : "SoftwareApplication", "name" : "Visual Studio Code", "softwareVersion": "1.95", "offers": { "@type": "Offer", "price": "0", "priceCurrency": "USD" }, "applicationCategory": "DeveloperApplication", "applicationSubCategory": "Text Editor", "alternateName": "VS Code", "datePublished": "2021-11-03", "operatingSystem": "Mac, Linux, Windows", "logo": "https://code.visualstudio.com/assets/apple-touch-icon.png", "screenshot": "https://code.visualstudio.com/assets/home/home-screenshot-win.png", "releaseNotes": "https://code.visualstudio.com/updates", "downloadUrl": "https://code.visualstudio.com/download", "license": "https://code.visualstudio.com/license", "softwareRequirements": "https://code.visualstudio.com/docs/supporting/requirements", "url" : "https://code.visualstudio.com", "author": { "@type": "Organization", "name": "Microsoft" }, "publisher": { "@type": "Organization", "name": "Microsoft" }, "maintainer": { "@type": "Organization", "name": "Microsoft" }, "potentialAction": { "@type": "SearchAction", "target": "https://code.visualstudio.com/Search?q={search_term_string}", "query-input": "required name=search_term_string" }, "sameAs" : [ "https://en.wikipedia.org/wiki/Visual_Studio_Code", "https://twitter.com/code", "https://www.youtube.com/code", "https://www.tiktok.com/@vscode", "https://github.com/microsoft/vscode" ] } </script> </body> </html>