VS Code Shortcuts

All good web editors have keyboard shortcuts and using VS Code in github.dev web-based editor is no exception. So when you are comfortable working in the editor, learning shortcuts is a great way to speed up your workflow.

Here are some handy keyboard shortcuts in Visual Studio Code that can make your coding experience smoother and faster.

Key - Windows/Linux / Mac

General Navigation

  • Ctrl + P / Cmd + P Quick Open – quickly open files by name.
  • Ctrl + Tab / Cmd + Tab Switch between open files.
  • Ctrl + G/ Cmd + GGo to line number in the current file.
  • Ctrl + Shift + O / Cmd + Shift + O Go to symbol in the current file.

Editing

  • Ctrl + L / Cmd + L Select the current line
  • Alt + Arrow Up/Down / Option + Arrow Up/Down Move the current line or selection up or down.
  • Ctrl + Shift + K / Cmd + Shift + K Delete the current line.
  • Ctrl + / / Cmd + / Toggle line comment.
  • Shift + Alt + A / Shift + Option + A Toggle block comment.
  • Home / Cmd + Left Arrow will take you to the start of the line.
  • End / Cmd + Right Arrow will take you to the end of the line.
  • Ctrl + End / Fn + Right Arrow will take you to the end of the file.
  • Ctrl + Home / Fn + Left Arrow will take you to the start of the file.
  • Backspace / Fn + Delete will delete a single character.
  • Ctrl + Backspace / Option + Delete will delete a whole word.

Multi-Cursor and Selection

  • Alt + Click / Option + Click Add a cursor at the clicked position.
  • Ctrl + Alt + Arrow Up/Down / Cmd + Option + Arrow Up/Down Insert cursors above or below.
  • Ctrl + D / Cmd + D Add the next occurrence of the selected word or phrase.

Search and Replace

  • Ctrl + F / Cmd + F Search within the file.
  • Ctrl + H / Cmd + Option + F Search and replace.
  • Ctrl + Shift + F / Cmd + Shift + F Search across all files.

Formatting

  • Shift + Alt + F / Shift + Option + F Format the current document.
  • Ctrl + K then Ctrl + F / Cmd + K then Cmd + F Format the current selection.

To wrap text with an HTML tag

Select the text in the page

Press Ctrl + Shift + p (opens the Command Palette) then type wrap and select Emmet: Wrap with Abbreviation then type the HTML tag you want such as p then press enter

This does not have a keyboard command defined, but if you click the Settings Cog icon whilst Emmet: Wrap with Abbreviation is displayed you can define your own. Personally I use Alt + t

To do this click the Settings Cog icon for Emmet: Wrap with Abbreviation

Then click the + and choose your key binding such as Alt + t then press enter

Now whenever you want to wrap text with HTML tag just press alt + t and the tag you want.

Note: these keyboard shortcuts are mainly aimed at using the web based version of VS Code that could be github.dev or vscode.dev, but many more services today use VS Code at the heart of their editing experience so you may be able to use these keys there too.

The one keyboard shortcut you need to be careful with when using the web based version is Ctrl + W which will close the browser tab. Our FAQ Oh No, I just closed my web editor tab! can help you if you do.

These keyboard shortcuts plus many more can also be used on the desktop version too.

What keyboard shortcut do you find useful? Let us know so we can add it here.

Explore other VS Code Shortcuts

We can also access a full list of VS Code shortcuts in a couple of ways as well as on the VS Code Docs website.

In the Editor

Go to the Activity bar (left side icon bar) and left click on "Settings" Settings Cog icon at the bottom of the bar.

Then select Keyboard Shortcuts from the options box.

The list of shortcuts will now open in your editor, showing the command, keybinding, when its usable and source of shortcut. It also has a useful search box along the top too.

How to add a shortcut

Let's add a "Go to repository" shortcut as currently it doesn't have one assigned to it.

First follow the above "In the Editor" instructions.

When you have the list of shortcuts in front of you type in the search box go to repos the list will then change to show the command we have entered (hopefully with no keybinding assigned).

Now click the Remote Repositories command, and then click on the + symbol Add keybinding (Enter) that appears.

You will now see an input box that says Press desired key combination and then press ENTER . Type in your chosen key combination e.g. Shift + R then press Enter (return)

If the combination you chose is already in use, a message telling you so will appear under the input box. To choose another you first need to clear the box by clicking the Esc Escape key then you can try again.

If you now check the pull down menu option "Go to repository" you will see your new keybinding shortcut listed next to it.

Pdf Version

You can also access a downloadable pdf version of shortcuts by going to the Activity bar again but this time left click on the "burger menu" Burger Menu icon at the top.

Select Help

Then select Keyboard Shortcuts Reference

A pdf will now open in a separate tab in your browser titled "Visual Studio Code keyboard shortcuts for windows".

VS Code Docs

You can find a condensed PDF version suitable for printing on the Keybinding page of Visual Studio Code's website, under "Keyboard Shortcuts Reference". Not using a windows machine? Don't worry as you can find platform specific shortcuts for both macOS and Linux systems there too.

Page Last Edited: