05-Visual Studio Code tips and tricks
05-Visual Studio Code tips and tricks
com/docs/getstarted/tips-and-tricks
(https://vscode.dev/github/microsoft/vscode-docs/blob/main/docs/getstarted/tips-and-tricks.md)
If you're just getting started, make sure to check out the VS Code tutorial (/docs/getstarted/getting-
started) for a step-by-step to discover the key features.
If you don't have Visual Studio Code installed, go to the Download (/download) page. You can find
platform specific setup instructions at Running VS Code on Linux (/docs/setup/linux), macOS (/docs/
setup/mac), and Windows (/docs/setup/windows).
Prefer a video? You can watch the VS Code Day talks Visual Studio Code tips and tricks (https://
learn.microsoft.com/en-us/events/visual-studio-code-vs-code-day-2021/vs-code-tips-and-tricks) or
Elevate your VS Code experience (https://learn.microsoft.com/en-us/shows/vs-code-day-2023/elevate-
your-vs-code-experience).
Basics
Getting started
The best way of exploring VS Code hands-on is to open the Welcome page and then pick a Walkthrough
for a self-guided tour through the setup steps, features, and deeper customizations that VS Code offers.
As you discover and learn, the walkthroughs track your progress.
Open the Welcome page from the Help > Welcome menu or use the Help: Welcome command from the
Command Palette ( ⇧⌘P ).
Extensions can also contribute walkthroughs. You can also directly open a walkthrough by using the Help:
Open Walkthrough... command from the Command Palette ( ⇧⌘P ).
If you are looking to improve your code editing skills, open the Interactive Editor Playground. Try out VS
Code's code editing features (/docs/editor/codebasics), like multi-cursor editing, IntelliSense (/docs/editor/
intellisense), Snippets, Emmet (/docs/editor/emmet), and more.
Open the Welcome page from the Help > Editor Playground menu or use the Help: Interactive Editor
Playground command from the Command Palette ( ⇧⌘P ).
Command Palette
Access all available commands based on your current context.
Tip
You can move the Command Palette to another location by grabbing the top edge with the mouse
cursor and dragging it somewhere else. You can also select the Customize Layout control in the title
bar, and then select one of the preconfigured Quick Input Positions.
Floating windows
You can open an editor in a floating window, for example to move the editor to another place on your
monitor or even to another monitor.
To open an editor in a floating window, drag it out of the main window and drop it anywhere outside of the
current VS Code window. Another way to detach an editor is to right-click on an editor tab, and select the
option Move into New Window ( workbench.action.moveEditorToNewWindow ) or Copy into New Window
( ⌘K O ).
Integrated Terminal
Keyboard Shortcut: ⌃`
You can select another terminal shell from the dropdown. Depending on your operating system and system
configuration, you might see different shells listed.
Further reading:
Toggle Sidebar
Keyboard Shortcut: ⌘B
Toggle Panel
Keyboard Shortcut: ⌘J
Zen mode
Enter distraction-free Zen mode.
Keyboard Shortcut: ⌘K Z
Command line
VS Code has a powerful command line interface (CLI) which enables you to customize how the editor is
launched to support various scenarios. For example, you can start VS Code from the command line to
open a diff editor for comparing two files.
Make sure the VS Code binary is on your path so you can simply type 'code' to launch VS Code. See
the platform specific setup topics if VS Code is added to your environment path during installation
(Running VS Code on Linux (/docs/setup/linux), macOS (/docs/setup/mac), Windows (/docs/setup/
windows)).
# open the current directory in the most recently used code window
code -r .
.vscode folder
Workspace-specific configuration files are in a .vscode folder at the root of your workspace. For
example, tasks.json for the Task Runner (/docs/editor/tasks) and launch.json for the debugger (/
docs/editor/debugging).
Status Bar
You can filter problem list either by type ('info', 'errors', 'warnings') or by matching text.
Keyboard Shortcut: ⌘K M
If you want to persist the new language mode for a file type, use the Configure File Association for
command to associate the current file extension with an installed language.
Customization
Keyboard Shortcut: ⌘K ⌘T
You can install more themes from the VS Code extension Marketplace (https://
marketplace.visualstudio.com/search?target=VSCode&category=Themes&sortBy=Installs). Select the
Preferences: Color Theme > + Browse Additional Color Themes... command to search themes from the
Marketplace.
Additionally, you can install and change your File Icon themes.
Keymaps
Are you used to keyboard shortcuts from another editor? You can install a Keymap extension that brings
the keyboard shortcuts from your favorite editor to VS Code. Use the Preferences: Keymaps command to
see the current list on the Visual Studio Marketplace (https://marketplace.visualstudio.com/search?
target=VSCode&category=Keymaps&sortBy=Installs).
• Vim (https://marketplace.visualstudio.com/items?itemName=vscodevim.vim)
• Sublime Text Keymap (https://marketplace.visualstudio.com/items?itemName=ms-vscode.sublime-
keybindings)
• Emacs Keymap (https://marketplace.visualstudio.com/items?itemName=hiro-sun.vscode-emacs)
• Atom Keymap (https://marketplace.visualstudio.com/items?itemName=ms-vscode.atom-
keybindings)
• Brackets Keymap (https://marketplace.visualstudio.com/items?itemName=ms-vscode.brackets-
keybindings)
• Eclipse Keymap (https://marketplace.visualstudio.com/items?itemName=alphabotsec.vscode-
eclipse-keybindings)
Keyboard Shortcut: ⌘K ⌘S
Select the pencil icon or use Enter on a specific entry to edit the keyboard shortcut. Filter the list by
using the search field.
You can also search for shortcuts and add your own keyboard shortcuts to the keybindings.json file.
Keyboard Shortcut: ⌘,
"window.zoomLevel": 5 Copy
Font ligatures
Tip: You need to have a font installed that supports font ligatures. FiraCode (https://github.com/
tonsky/FiraCode) is a popular font on the VS Code team.
Auto Save
You can also toggle Auto Save from the top-level menu with the File > Auto Save.
Format on save
Format on paste
"editor.tabSize": 4 Copy
Spaces or Tabs
Render whitespace
"files.exclude": { Copy
"somefolder/": true,
"somefile": true
}
"search.exclude": { Copy
"someFolder/": true,
"somefile": true
}
"[languageid]": { Copy
Tip: You can also create language-specific settings with the Configure Language Specific Settings
command.
"json.schemas": [ Copy
{
"fileMatch": [
"bower.json"
],
"url": "https://json.schemastore.org/bower"
}
]
"json.schemas": [ Copy
{
"fileMatch": [
"**/foo.json"
],
"url": "./myschema.json"
}
]
"json.schemas": [ Copy
{
"fileMatch": [
"/.myconfig"
],
"schema": {
"type": "object",
"properties": {
"name" : {
"type": "string",
"description": "The name of the entry"
}
}
}
}
]
Specify the full path to the browser executable as the settings value. Alternatively, to ensure correct
functioning across devices, you can also use browser aliases, such as edge , chrome , or firefox .
analyze related log information from multiple services, you can combine multiple logs into a single
compound log.
Select Create Compound Log... from the overflow menu of the Output panel.
Extensions
Find extensions
You can use multiple sources to find extensions:
Extension recommendations
In the Extensions view, select the Filter control, and then select Recommended to view the list of
recommended extensions.
• configuration
• commands
• keyboard shortcuts
• languages
• debuggers
• grammars
• themes
• snippets
• jsonValidation
After you enable the Simple File Dialog, you can browse and select files and folders by using a Quick Pick
inside VS Code.
To enable the simple file dialog, configure the files.simpleDialog setting (/docs/editor/settings):
Quick Open
Quickly search and open files.
Keyboard Shortcut: ⌘P
Typing commands such as edt or term followed by a space brings up a dropdown list.
Repeatedly press the Quick Open keyboard shortcut to cycle quickly between recently opened files.
You can open multiple files from Quick Open by pressing Right Arrow . This opens the currently selected
file in the background, and you can continue selecting files from Quick Open.
Keyboard Shortcut: ⌃R
Displays a Quick Pick dropdown with the list from File > Open Recent with recently opened folders and
You can quickly open a file or image, or create a new file by moving the cursor to the file link and then
pressing Ctrl+click .
Navigation history
Navigate entire history: ⌃Tab
Navigate back: ⌃-
File associations
Create language associations for files that aren't detected correctly. For example, many configuration files
with custom file extensions are actually JSON.
"files.associations": { Copy
".database": "json"
}
To resolve the save conflict, select the Compare action in the notification popup to open a diff editor that
shows you the contents of the file on disk (to the left) compared to the contents in VS Code (on the right):
Use the actions in the editor toolbar to resolve the save conflict. You can either Accept your changes and
thereby overwriting any changes on disk, or Revert to the version on disk. Reverting means that your
changes will be lost.
Note: The file remains dirty and cannot be saved until you pick one of the two actions to resolve the
conflict.
Editing hacks
Here is a selection of common features for editing code. If you're more familiar with the keyboard
shortcuts for another editor, consider installing a keymap extension (https://marketplace.visualstudio.com/
search?target=VSCode&category=Keymaps&sortBy=Installs).
Tip: You can see recommended keymap extensions in the Extensions view by filtering the search to
@recommended:keymaps .
You can also drag and drop editors to create new editor groups and move editors between groups.
You can add additional cursors to all occurrences of the current selection with ⇧⌘L .
Note: You can also change the modifier to Ctrl/Cmd for applying multiple cursors with the
! (vscode://settings/editor.multiCursorModifier)editor.multiCursorModifier setting (/docs/editor/
settings) . See Multi-cursor Modifier (/docs/editor/codebasics#_multicursor-modifier) for details.
If you do not want to add all occurrences of the current selection, you can use ⌘D instead. This only
selects the next occurrence after the one you selected so you can add selections one by one.
Vertical rulers
You can add vertical column rulers to the editor with the ! (vscode://settings/editor.rulers)editor.rulers
setting, which takes an array of column character positions where you'd like vertical rulers.
{ Copy
"editor.rulers": [20, 40, 60]
}
Fast scrolling
Pressing the Alt key enables fast scrolling in the editor and Explorers. By default, fast scrolling uses a 5X
speed multiplier but you can control the multiplier with the Editor: Fast Scroll Sensitivity (
! (vscode://settings/editor.fastScrollSensitivity)editor.fastScrollSensitivity ) setting.
Locked scrolling
You can synchronize scrolling across all visible editors by using the View: Toggle Locked Scrolling Across
Editors command. This means that when you scroll in one editor, all the other editors scroll by the same
amount, keeping everything aligned.
You can choose to only activate the scrolling sync when you're holding down a specific keyboard shortcut.
Set up a keyboard shortcut for the workbench.action.holdLockedScrolling command to temporarily
lock scrolling across editors.
The commands Copy Line Up/Down are unbound on Linux because the VS Code default keyboard
shortcuts would conflict with Ubuntu keyboard shortcuts, see Issue #509 (https://github.com/
microsoft/vscode/issues/509). You can still set the commands editor.action.copyLinesUpAction
and editor.action.copyLinesDownAction to your own preferred keyboard shortcuts.
Go to Symbol in File
Keyboard Shortcut: ⇧⌘O
Go to Symbol in Workspace
Keyboard Shortcut: ⌘T
Outline view
The Outline view in the File Explorer (default collapsed at the bottom) shows you the symbols of the
currently open file.
You can sort by symbol name, category, and position in the file and allows quick navigation to symbol
locations.
Code formatting
Currently selected source code: ⌘K ⌘F
Code folding
Keyboard Shortcut: ⌥⌘[ , ⌥⌘] and ⌘K ⌘L
You can also fold/unfold all regions in the editor with Fold All ( ⌘K ⌘0 ) and Unfold All ( ⌘K ⌘J ).
You can fold all block comments with Fold All Block Comments ( ⌘K ⌘/ ).
Keyboard Shortcut: ⌘K V
The preview and editor will synchronize with your scrolling in either view.
IntelliSense
You can view available methods, parameter hints, short documentation, etc.
Peek
Select a symbol then type ⌥F12 . Alternatively, you can use the context menu.
Go to Definition
Select a symbol then type F12 . Alternatively, you can use the context menu or Ctrl+click ( Cmd+click
on macOS).
You can go back to your previous location with the Go > Back command or ⌃- .
You can also see the type definition if you press Ctrl ( Cmd on macOS) when you are hovering over the
type.
Go to References
Select a symbol then type ⇧F12 . Alternatively, you can use the context menu.
Rename Symbol
Select a symbol then type F2 . Alternatively, you can use the context menu.
.eslintrc.json
Install the ESLint extension (https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-
eslint). Configure your linter however you'd like. Consult the ESLint specification (https://eslint.org/docs/
user-guide/configuring) for details on its linting rules and options.
{ Copy
"env": {
"browser": true,
"commonjs": true,
"es6": true,
"node": true
},
"parserOptions": {
"ecmaVersion": 6,
"sourceType": "module",
"ecmaFeatures": {
"jsx": true,
"classes": true,
"defaultParams": true
}
},
"rules": {
"no-const-assign": 1,
"no-extra-semi": 0,
"semi": 0,
"no-fallthrough": 0,
"no-empty": 0,
"no-mixed-spaces-and-tabs": 0,
"no-redeclare": 0,
"no-this-before-super": 1,
"no-undef": 1,
"no-unreachable": 1,
"no-use-before-define": 0,
"constructor-super": 1,
"curly": 0,
"eqeqeq": 0,
"func-names": 0,
"valid-typeof": 1
}
}
package.json
See IntelliSense for your package.json file.
Emmet syntax
Support for Emmet syntax (/docs/editor/emmet).
Snippets
Git integration
Git integration comes "out-of-the-box" with VS Code. You can install other source control management
(SCM) providers from the VS Code Extension Marketplace (/docs/editor/extension-marketplace). This
section describes the Git integration but much of the UI and gestures are common for other SCM
providers.
Git blame
VS Code shows git blame information inline in the editor and in the Status Bar. Hover over the Status Bar
item or inline hint to view detailed git blame information.
Screenshot that shows Git blame information when hovering over the git blame item in the Status Bar.
To enable or disable git blame information, use the Git: Toggle Git Blame Editor Decoration and Git:
Toggle Git Blame Status Bar Item commands, or configure these settings:
• ! (vscode://settings/git.blame.statusBarItem.enabled)git.blame.statusBarItem.enabled (enabled
by default)
• ! (vscode://settings/git.blame.editorDecoration.enabled)git.blame.editorDecoration.enabled
Diffs
From the Source Control view, select a file to open the diff editor. Alternatively, select the Open Changes
button in the top right corner to diff the current open file.
Views
Toggle inline view by selecting the More Actions (...) button in the top right, and then selecting Inline
View.
If you prefer to have the inline view as the default, configure the "diffEditor.renderSideBySide":
false setting.
Navigate through diffs with F7 and ⇧F7 . This presents changes in a unified patch format. Lines can be
navigated with arrow keys and pressing Enter jumps back in the diff editor and the selected line.
While you're viewing changes in the diff editor, you can make edits directly in the pending changes side of
the diff editor.
Branches
Easily switch between Git branches via the Status Bar.
Staging
Hover over the number of files and select the plus button to stage a file.
Stage selected
You can stage a portion of a file by making a text selection in a file and then choosing Stage Selected
Ranges from the Command Palette or from the diff editor context menu (right-click).
To view the Git output, select the (...) button in the Source Control view, and then select Show Git Output,
use the Git: Show Git Output command, or use the Toggle Output command ( ⇧⌘U ) and then select Git
from the dropdown.
Gutter indicators
The editor provides visual cues in the gutter about where and which changes (added, changed, or remove
You can resolve merge conflicts with the inline CodeLens which lets you Accept Current Change, Accept
Incoming Change, Accept Both Changes, and Compare Changes.
Keyboard Shortcut: ⌘K C
Quickly compare the active file with the contents of the clipboard with the File: Compare Active File with
Clipboard command in the Command Palette ( ⇧⌘P ).
Debugging
Configure debugger
From the Run and Debug view ( ⇧⌘D ), select create a launch.json file, which prompts you to select the
environment that matches your project (Node.js, Python, C++, and more). This generates a launch.json
file in your workspace that contains the debugger configuration.
Node.js support is built-in and other environments require installing the appropriate language extensions.
See the debugging documentation (/docs/editor/debugging) for more details.
Once a debug session starts, the Debug toolbar appears on the top of the editor and enables you to step
through or into the code while debugging. Learn more about debug actions (/docs/editor/
debugging#_debug-actions) in the debugging documentation.
Data inspection
Variables can be inspected in the VARIABLES section of the Run and Debug view, by hovering over their
Logpoints
Logpoints act much like breakpoints but instead of halting the debugger when they are hit, they log a
message to the console. Logpoints are especially useful for injecting logging while debugging production
servers that cannot be modified or paused.
Add a logpoint with the Add Logpoint command in the left editor gutter and it will be displayed as a
"diamond" shaped icon. Log messages are plain text but can include expressions to be evaluated within
curly braces ('{}').
Triggered breakpoints
A triggered breakpoint is a breakpoint that is automatically enabled once another breakpoint is hit. They
can be very useful when diagnosing failure cases in code that happen only after a certain precondition.
Triggered breakpoints can be set by right-clicking on the glyph margin, selecting Add Triggered
Breakpoint, and then choosing which other breakpoint enables the breakpoint.
Task runner
Tasks in VS Code can be configured to run scripts and start processes so that these tools can be used
from within VS Code without having to enter a command line or write new code.
{ Copy
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "install",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
There are occasionally issues with auto generation. Check out the documentation for getting things to
work properly.
For example, to bind Ctrl+H to the Run tests task, add the following:
{ Copy
"key": "ctrl+h",
"command": "workbench.action.tasks.runTask",
"args": "Run tests"
}
Portable mode
VS Code has a Portable mode (/docs/editor/portable) which lets you keep settings and data in the same
location as your installation, for example, on a USB drive.
Insiders builds
The Visual Studio Code team uses the Insiders version to test the latest features and bug fixes of VS
Code. You can also use the Insiders version by downloading it here (/insiders).
• For Early Adopters - Insiders has the most recent code changes for users and extension authors to
try out.
• Frequent Builds - New builds every day with the latest bug fixes and features.
• Side-by-side install - Insiders installs next to the Stable build allowing you to use either
independently.
Yes No
02/06/2025
Follow @code(https://go.microsoft.com/fwlink/?LinkID=533687)
Request features(https://go.microsoft.com/fwlink/?LinkID=533482)
Report issues(https://www.github.com/Microsoft/vscode/issues)
Watch videos(https://www.youtube.com/channel/UCs5Y5_7XK8HLDX0SLNwkd3w)
(https://
www.microsoft.com)
(https://go.microsoft.com/fwlink/?LinkID=533687)
(https://github.com/microsoft/vscode) (https://www.youtube.com/@code)
Support (https://support.serviceshub.microsoft.com/supportforbusiness/create?sapId=d66407ed-3967-
b000-4cfb-2c318cad363d)
Privacy (https://go.microsoft.com/fwlink/?LinkId=521839)
Terms of Use (https://www.microsoft.com/legal/terms-of-use) License (/License)