Keyboard Shortcut For Commenting In Visual Studio Mac

Posted on  by 

Visual Studio 2017 keyboard shortcuts The complete list. 2012; 2013; 2015; 2017; Build Build Solution Ctrl+Shift+B Cancel. Add Comment Ctrl+Shift+K Edit Local File Ctrl+Shift+P Execute Ctrl+Alt+F5 Go To View. 578 shortcuts in total. Get the Visual Studio extension.

  1. Keyboard Shortcut For Commenting In Visual Studio Mac Osx
  2. Block Comment Visual Studio Shortcut
By Steve Endow
A very handy feature in Visual Studio is the Comment / Uncomment editing option.
There are two buttons that allow you to comment or uncomment code with a single click.
While those buttons are handy, they require you to use the mouse, and that can sometimes be tedious if you are having to also make multiple code selections with the mouse.
Visual Studio does have keyboard shortcuts for Comment and Uncomment, but they are the unfortunate double-shortcut combinations: Ctrl+K, Ctrl+C to comment, and Ctrl+K, Ctrl+U to uncomment.
I find those shortcuts to be pretty annoying, as they require me to use both hands to press those key combinations. It's not much of a 'shortcut'.
After several years of this nagging me, I finally bothered to lookup a better alternative. Fortunately Visual Studio allows you to add your own keyboard shortcuts. If you click on Tools -> Options, and then select Environment -> Keyboard, you can select a command and assign a new keyboard shortcut.
The one challenge is finding a decent keyboard shortcut that isn't already taken.
I entered the word 'comment' and it displayed the relevant commands. I then selected Edit.CommentSelection, selected Use new shortcut in Text Editor, pressed Alt+C, then clicked Assign.
Now I can comment a selection using the nice and simple Alt+C shortcut. Big improvement.

I don't Uncomment as much, so for now I haven't assigned a custom shortcut to Edit.Uncomment, but at least I now know it's very easy to do.
Keep on coding...and commenting...
Steve Endow is a Microsoft MVPfor Dynamics GP and a Dynamics GP Certified IT Professional in Los Angeles. He is the owner of Precipio Services, which provides Dynamics GPintegrations, customizations, and automation solutions.
You can also find him on Twitter, YouTube, and Google+

http://www.precipioservices.com

Visual Studio Code lets you perform most tasks directly from the keyboard. This page lists out the default bindings (keyboard shortcuts) and describes how you can update them.

Note: If you visit this page on a Mac, you will see the key bindings for the Mac. If you visit using Windows or Linux, you will see the keys for that platform. If you need the key bindings for another platform, hover your mouse over the key you are interested in.

Keyboard Shortcuts editor

Visual Studio Code provides a rich and easy keyboard shortcuts editing experience using Keyboard Shortcuts editor. It lists all available commands with and without keybindings and you can easily change / remove / reset their keybindings using the available actions. It also has a search box on the top that helps you in finding commands or keybindings. You can open this editor by going to the menu under File > Preferences > Keyboard Shortcuts. (Code > Preferences > Keyboard Shortcuts on macOS)

Most importantly, you can see keybindings according to your keyboard layout. For example, key binding Cmd+ in US keyboard layout will be shown as Ctrl+Shift+Alt+Cmd+7 when layout is changed to German. The dialog to enter key binding will assign the correct and desired key binding as per your keyboard layout.

For doing more advanced keyboard shortcut customization, read Advanced Customization.

Keymap extensions

Keyboard shortcuts are vital to productivity and changing keyboarding habits can be tough. To help with this, File > Preferences > Keymap Extensions shows you a list of popular keymap extensions. These extensions modify the VS Code shortcuts to match those of other editors so you don't need to learn new keyboard shortcuts. There is also a Keymaps category of extensions in the Marketplace.

Tip: Click on an extension tile above to read the description and reviews to decide which extension is best for you. See more in the Marketplace.

Keyboard Shortcuts Reference

We also have a printable version of these keyboard shortcuts. Help > Keyboard Shortcut Reference displays a condensed PDF version suitable for printing as an easy reference.

Below are links to the three platform-specific versions:

Detecting keybinding conflicts

If you have many extensions installed or you have customized your keyboard shortcuts, you can sometimes have keybinding conflicts where the same keyboard shortcut is mapped to several commands. This can result in confusing behavior, especially if different keybindings are going in and out of scope as you move around the editor.

The Keyboard Shortcuts editor has a context menu command Show Same Keybindings, which will filter the keybindings based on a keyboard shortcut to display conflicts.

Pick a command with the keybinding you think is overloaded and you can see if multiple commands are defined, the source of the keybindings and when they are active.

Advanced customization

All keyboard shortcuts in VS Code can be customized via the keybindings.json file.

  • To configure keyboard shortcuts the way you want, open Keyboard Shortcuts editor and click on {} button on the right of the editor title bar.
  • This will open your keybindings.json file where you can overwrite the Default Keybindings.

Keyboard rules

The keyboard shortcuts dispatching is done by analyzing a list of rules that are expressed in JSON. Here are some examples:

Each rule consists of:

  • a key that describes the pressed keys.
  • a command containing the identifier of the command to execute.
  • an optionalwhen clause containing a boolean expression that will be evaluated depending on the current context.

Chords (two separate keypress actions) are described by separating the two keypresses with a space. For example, Ctrl+K Ctrl+C.

When a key is pressed:

  • the rules are evaluated from bottom to top.
  • the first rule that matches, both the key and in terms of when, is accepted.
  • no more rules are processed.
  • if a rule is found and has a command set, the command is executed.

The additional keybindings.json rules are appended at runtime to the bottom of the default rules, thus allowing them to overwrite the default rules. The keybindings.json file is watched by VS Code so editing it while VS Code is running will update the rules at runtime.

Accepted keys

The key is made up of modifiers and the key itself.

The following modifiers are accepted:

PlatformModifiers
macOSCtrl+, Shift+, Alt+, Cmd+
WindowsCtrl+, Shift+, Alt+, Win+
LinuxCtrl+, Shift+, Alt+, Meta+

The following keys are accepted:

  • f1-f19, a-z, 0-9
  • `, -, =, [, ], , ;, ', ,, ., /
  • left, up, right, down, pageup, pagedown, end, home
  • tab, enter, escape, space, backspace, delete
  • pausebreak, capslock, insert
  • numpad0-numpad9, numpad_multiply, numpad_add, numpad_separator
  • numpad_subtract, numpad_decimal, numpad_divide

Command arguments

You can invoke a command with arguments. This is useful if you often perform the same operation on a specific file or folder. You can add a custom keyboard shortcut to do exactly what you want.

The following is an example overriding the Enter key to print some text:

The type command will receive {'text': 'Hello World'} as its first argument and add 'Hello World' to the file instead of producing the default command.

For more information on commands that take arguments, refer to Built-in Commands.

Removing a specific key binding rule

You can write a key binding rule that targets the removal of a specific default key binding. With the keybindings.json, it was always possible to redefine all the key bindings of VS Code, but it can be difficult to make a small tweak, especially around overloaded keys, such as Tab or Escape. To remove a specific key binding, add a - to the command and the rule will be a removal rule.

Here is an example:

Keyboard layouts

Note: This section relates only to key bindings, not to typing in the editor.

The keys above are string representations for virtual keys and do not necessarily relate to the produced character when they are pressed. More precisely:

  • Reference: Virtual-Key Codes (Windows)
  • tab for VK_TAB (0x09)
  • ; for VK_OEM_1 (0xBA)
  • = for VK_OEM_PLUS (0xBB)
  • , for VK_OEM_COMMA (0xBC)
  • - for VK_OEM_MINUS (0xBD)
  • . for VK_OEM_PERIOD (0xBE)
  • / for VK_OEM_2 (0xBF)
  • ` for VK_OEM_3 (0xC0)
  • [ for VK_OEM_4 (0xDB)
  • for VK_OEM_5 (0xDC)
  • ] for VK_OEM_6 (0xDD)
  • ' for VK_OEM_7 (0xDE)
  • etc.

Different keyboard layouts usually reposition the above virtual keys or change the characters produced when they are pressed. When using a different keyboard layout than the standard US, Visual Studio Code does the following:

All the key bindings are rendered in the UI using the current system's keyboard layout. For example, Split Editor when using a French (France) keyboard layout is now rendered as Ctrl+*:

When editing keybindings.json, VS Code highlights misleading key bindings, those that are represented in the file with the character produced under the standard US keyboard layout, but that need pressing keys with different labels under the current system's keyboard layout. For example, here is how the Default Keyboard Shortcuts rules look like when using a French (France) keyboard layout:

There is also a widget that helps input the key binding rule when editing keybindings.json. To launch the Define Keybinding widget, press ⌘K ⌘K (Windows, Linux Ctrl+K Ctrl+K). The widget listens for key presses and renders the serialized JSON representation in the text box and below it, the keys that VS Code has detected under your current keyboard layout. Once you've typed the key combination you want, you can press Enter and a rule snippet will be inserted.

Note: On Linux, Visual Studio Code detects your current keyboard layout on start-up and then caches this information. For a good experience, we recommend restarting VS Code if you change your keyboard layout.

Keyboard layout-independent bindings

Using scan codes, it is possible to define keybindings which do not change with the change of the keyboard layout. For example:

Accepted scan codes:

  • [F1]-[F19], [KeyA]-[KeyZ], [Digit0]-[Digit9]
  • [Backquote], [Minus], [Equal], [BracketLeft], [BracketRight], [Backslash], [Semicolon], [Quote], [Comma], [Period], [Slash]
  • [ArrowLeft], [ArrowUp], [ArrowRight], [ArrowDown], [PageUp], [PageDown], [End], [Home]
  • [Tab], [Enter], [Escape], [Space], [Backspace], [Delete]
  • [Pause], [CapsLock], [Insert]
  • [Numpad0]-[Numpad9], [NumpadMultiply], [NumpadAdd], [NumpadComma]
  • [NumpadSubtract], [NumpadDecimal], [NumpadDivide]

'when' clause contexts

VS Code gives you fine control over when your key bindings are enabled through the optional when clause. If your key binding doesn't have a when clause, the key binding is globally available at all times.

Below are some of the possible when clause contexts which evaluate to Boolean true/false. For conditional expressions, you can use either equality ('editorLangId typescript') or inequality != ('resourceExtname != .js').

Context nameTrue when
Editor contexts
editorFocusAn editor has focus, either the text or a widget.
editorTextFocusThe text in an editor has focus (cursor is blinking).
textInputFocusAny editor has focus (regular editor, debug REPL, etc.).
inputFocusAny text input area has focus (editors or text boxes).
editorHasSelectionText is selected in the editor.
editorHasMultipleSelectionsMultiple regions of text are selected (multiple cursors).
editorReadonlyThe editor is read only.
editorLangIdTrue when the editor's associated language Id matches. Example: 'editorLangId typescript'.
isInDiffEditorThe active editor is a difference editor.
isInEmbeddedEditorTrue when the focus is inside an embedded editor.
Operating system contexts
isLinuxTrue when the OS is Linux
isMacTrue when the OS is macOS
isWindowsTrue when the OS is Windows
isWebTrue when accessing the editor from the Web
List contexts
listFocusA list has focus.
listSupportsMultiselectA list supports multi select.
listHasSelectionOrFocusA list has selection or focus.
listDoubleSelectionA list has a selection of 2 elements.
listMultiSelectionA list has a selection of multiple elements.
Mode contexts
inDebugModeA debug session is running.
debugTypeTrue when debug type matches. Example: 'debugType 'node'.
inSnippetModeThe editor is in snippet mode.
inQuickOpenThe Quick Open drop-down has focus.
Resource contexts
resourceSchemeTrue when the resource Uri scheme matches. Example: 'resourceScheme file'
resourceFilenameTrue when the Explorer or editor filename matches. Example: 'resourceFilename gulpfile.js'
resourceExtnameTrue when the Explorer or editor filename extension matches. Example: 'resourceExtname .js'
resourceLangIdTrue when the Explorer or editor title language Id matches. Example: 'resourceLangId markdown'
isFileSystemResourceisFileSystemResourceTrue when the Explorer or editor file is a file system resource that can be handled from a file system provider
resourceSetTrue when an Explorer or editor file is set
resourceThe full Uri of the Explorer or editor file
Explorer contexts
explorerViewletVisibleTrue if Explorer view is visible.
explorerViewletFocusTrue if Explorer view has keyboard focus.
filesExplorerFocusTrue if File Explorer section has keyboard focus.
openEditorsFocusTrue if OPEN EDITORS section has keyboard focus.
explorerResourceIsFolderTrue if a folder is selected in the Explorer.
Editor widget contexts
findWidgetVisibleEditor Find widget is visible.
suggestWidgetVisibleSuggestion widget (IntelliSense) is visible.
suggestWidgetMultipleSuggestionsMultiple suggestions are displayed.
renameInputVisibleRename input text box is visible.
referenceSearchVisiblePeek References peek window is open.
inReferenceSearchEditorThe Peek References peek window editor has focus.
config.editor.stablePeekKeep peek editors open (controlled by editor.stablePeek setting).
quickFixWidgetVisibleQuick Fix widget is visible.
parameterHintsVisibleParameter hints are visible (controlled by editor.parameterHints.enabled setting).
parameterHintsMultipleSignaturesMultiple parameter hints are displayed.
Integrated terminal contexts
terminalFocusAn integrated terminal has focus.
terminalIsOpenAn integrated terminal is opened.
Global UI contexts
notificationFocusNotification has keyboard focus.
notificationCenterVisibleNotification Center is visible at the bottom right of VS Code.
notificationToastsVisibleNotification toast is visible at the bottom right of VS Code.
searchViewletVisibleSearch view is open.
sideBarVisibleSide Bar is displayed.
sideBarFocusSide Bar has focus.
panelFocusPanel has focus.
inZenModeWindow is in Zen Mode.
isCenteredLayoutEditor is in centered layout mode.
inDebugReplFocus is in the Debug Console REPL.
workspaceFolderCountCount of workspace folders.
replaceActiveSearch view Replace text box is open.
viewTrue when view identifier matches. Example: 'view myViewsExplorerID'.
viewItemTrue when viewItem context matches. Example: 'viewItem someContextValue'.
isFullscreenTrue when window is in fullscreen.
focusedViewThe identifier of the currently focused view.
canNavigateBackTrue if it is possible to navigate back.
canNavigateForwardTrue if it is possible to navigate forward.
canNavigateToLastEditLocationTrue if it is possible to navigate to the last edit location.
Global Editor UI contexts
textCompareEditorVisibleAt least one diff (compare) editor is visible.
textCompareEditorActiveA diff (compare) editor is active.
editorIsOpenTrue if one editor is open.
groupActiveEditorDirtyTrue when the active editor in a group is dirty.
groupEditorsCountNumber of editors in a group.
activeEditorGroupEmptyTrue if the active editor group has no editors.
activeEditorGroupIndexIndex of the active editor in an group (beginning with 1).
activeEditorGroupLastTrue when the active editor in an group is the last one.
multipleEditorGroupsTrue when multiple editor groups are present.
editorPinnedTrue when the active editor in a group is pinned (not in preview mode).
activeEditorThe identifier of the active editor in a group.
Configuration settings contexts
config.editor.minimap.enabledTrue when the setting editor.minimap.enabled is true.
Visual

Note: You can use any user or workspace setting that evaluates to a boolean here with the prefix 'config.'.

The list above isn't exhaustive and you may see some when contexts for specific VS Code UI in the Default Keyboard Shortcuts.

Active/Focused view or panel 'when' clause context

You can have a keybinding that is enabled only when a specific view or panel is visible.

Context nameTrue when
activeViewletTrue when view is visible. Example: 'activeViewlet 'workbench.view.explorer'
activePanelTrue when panel is visible. Example: 'activePanel 'workbench.panel.output'
focusedViewTrue when view is focused. Example: 'focusedView myViewsExplorerID

View Identifiers:

  • workbench.view.explorer - File Explorer
  • workbench.view.search - Search
  • workbench.view.scm - Source Control
  • workbench.view.debug - Debug
  • workbench.view.extensions - Extensions

Panel Identifiers:

  • workbench.panel.markers - Problems
  • workbench.panel.output - Output
  • workbench.panel.repl - Debug Console
  • workbench.panel.terminal - Integrated Terminal
  • workbench.panel.comments - Comments
  • workbench.view.search - Search when search.location is set to panel

If you want a keybinding that is enabled only when a specific view or panel has focus, use sideBarFocus or panelFocus in combination with activeViewlet or activiewFocus.

For example, the when clause below is true only when the File Explorer has focus:

key-value when clause operator

There is a key-value pair operator for when clauses. The expression key =~ value treats the right hand side as a regular expression to match against the left hand side. For example, to contribute context menu items for all Docker files, one could use:

Keyboard Shortcut For Commenting In Visual Studio Mac Osx

Custom keybindings for refactorings

The editor.action.codeAction command lets you configure keybindings for specific Refactorings (Code Actions). For example, the keybinding below triggers the Extract function refactoring Code Actions:

This is covered in depth in the Refactoring topic where you can learn about different kinds of Code Actions and how to prioritize them in the case of multiple possible refactorings.

Default Keyboard Shortcuts

You can view all default keyboard shortcuts in VS Code in the Keyboard Shortcuts editor

or as a JSON file using the command Preferences: Open Default Keyboard Shortcuts (JSON).

Note: The following keys are rendered assuming a standard US keyboard layout. If you use a different keyboard layout, please read below. You can view the currently active keyboard shortcuts in VS Code in the Command Palette (View -> Command Palette) or in the Keyboard Shortcuts editor (File > Preferences > Keyboard Shortcuts).

Some commands included below do not have default keyboard shortcuts and so are displayed as unassigned but you can assign your own keybindings.

Basic Editing

KeyCommandCommand id
⌘X (Windows, Linux Ctrl+X)Cut line (empty selection)editor.action.clipboardCutAction
⌘C (Windows, Linux Ctrl+C)Copy line (empty selection)editor.action.clipboardCopyAction
⇧⌘K (Windows, Linux Ctrl+Shift+K)Delete Lineeditor.action.deleteLines
⌘Enter (Windows, Linux Ctrl+Enter)Insert Line Beloweditor.action.insertLineAfter
⇧⌘Enter (Windows, Linux Ctrl+Shift+Enter)Insert Line Aboveeditor.action.insertLineBefore
⌥↓ (Windows, Linux Alt+Down)Move Line Downeditor.action.moveLinesDownAction
⌥↑ (Windows, Linux Alt+Up)Move Line Upeditor.action.moveLinesUpAction
⇧⌥↓ (Windows Shift+Alt+Down, Linux Ctrl+Shift+Alt+Down)Copy Line Downeditor.action.copyLinesDownAction
⇧⌥↑ (Windows Shift+Alt+Up, Linux Ctrl+Shift+Alt+Up)Copy Line Upeditor.action.copyLinesUpAction
⌘D (Windows, Linux Ctrl+D)Add Selection To Next Find Matcheditor.action.addSelectionToNextFindMatch
⌘K ⌘D (Windows, Linux Ctrl+K Ctrl+D)Move Last Selection To Next Find Matcheditor.action.moveSelectionToNextFindMatch
⌘U (Windows, Linux Ctrl+U)Undo last cursor operationcursorUndo
⇧⌥I (Windows, Linux Shift+Alt+I)Insert cursor at end of each line selectededitor.action.insertCursorAtEndOfEachLineSelected
⇧⌘L (Windows, Linux Ctrl+Shift+L)Select all occurrences of current selectioneditor.action.selectHighlights
⌘F2 (Windows, Linux Ctrl+F2)Select all occurrences of current wordeditor.action.changeAll
⌘L (Windows, Linux Ctrl+L)Select current lineexpandLineSelection
⌥⌘↓ (Windows Ctrl+Alt+Down, Linux Shift+Alt+Down)Insert Cursor Beloweditor.action.insertCursorBelow
⌥⌘↑ (Windows Ctrl+Alt+Up, Linux Shift+Alt+Up)Insert Cursor Aboveeditor.action.insertCursorAbove
⇧⌘ (Windows, Linux Ctrl+Shift+)Jump to matching bracketeditor.action.jumpToBracket
⌘] (Windows, Linux Ctrl+])Indent Lineeditor.action.indentLines
⌘[ (Windows, Linux Ctrl+[)Outdent Lineeditor.action.outdentLines
HomeGo to Beginning of LinecursorHome
EndGo to End of LinecursorEnd
⌘↓ (Windows, Linux Ctrl+End)Go to End of FilecursorBottom
⌘↑ (Windows, Linux Ctrl+Home)Go to Beginning of FilecursorTop
⌃PageDown (Windows, Linux Ctrl+Down)Scroll Line DownscrollLineDown
⌃PageUp (Windows, Linux Ctrl+Up)Scroll Line UpscrollLineUp
⌘PageDown (Windows, Linux Alt+PageDown)Scroll Page DownscrollPageDown
⌘PageUp (Windows, Linux Alt+PageUp)Scroll Page UpscrollPageUp
⌥⌘[ (Windows, Linux Ctrl+Shift+[)Fold (collapse) regioneditor.fold
⌥⌘] (Windows, Linux Ctrl+Shift+])Unfold (uncollapse) regioneditor.unfold
⌘K ⌘[ (Windows, Linux Ctrl+K Ctrl+[)Fold (collapse) all subregionseditor.foldRecursively
⌘K ⌘] (Windows, Linux Ctrl+K Ctrl+])Unfold (uncollapse) all subregionseditor.unfoldRecursively
⌘K ⌘0 (Windows, Linux Ctrl+K Ctrl+0)Fold (collapse) all regionseditor.foldAll
⌘K ⌘J (Windows, Linux Ctrl+K Ctrl+J)Unfold (uncollapse) all regionseditor.unfoldAll
⌘K ⌘C (Windows, Linux Ctrl+K Ctrl+C)Add Line Commenteditor.action.addCommentLine
⌘K ⌘U (Windows, Linux Ctrl+K Ctrl+U)Remove Line Commenteditor.action.removeCommentLine
⌘/ (Windows, Linux Ctrl+/)Toggle Line Commenteditor.action.commentLine
⇧⌥A (Windows Shift+Alt+A, Linux Ctrl+Shift+A)Toggle Block Commenteditor.action.blockComment
⌘F (Windows, Linux Ctrl+F)Findactions.find
⌥⌘F (Windows, Linux Ctrl+H)Replaceeditor.action.startFindReplaceAction
EnterFind Nexteditor.action.nextMatchFindAction
⇧⌘G (Windows, Linux Shift+Enter)Find Previouseditor.action.previousMatchFindAction
⌥Enter (Windows, Linux Alt+Enter)Select All Occurrences of Find Matcheditor.action.selectAllMatches
⌥⌘C (Windows, Linux Alt+C)Toggle Find Case SensitivetoggleFindCaseSensitive
⌥⌘R (Windows, Linux Alt+R)Toggle Find RegextoggleFindRegex
⌥⌘W (Windows, Linux Alt+W)Toggle Find Whole WordtoggleFindWholeWord
⌃⇧M (Windows, Linux Ctrl+M)Toggle Use of Tab Key for Setting Focuseditor.action.toggleTabFocusMode
Toggle Render WhitespacetoggleRenderWhitespace
⌥Z (Windows, Linux Alt+Z)Toggle Word Wrapeditor.action.toggleWordWrap

Rich Languages Editing

KeyCommandCommand id
⌃Space (Windows, Linux Ctrl+Space)Trigger Suggesteditor.action.triggerSuggest
⇧⌘Space (Windows, Linux Ctrl+Shift+Space)Trigger Parameter Hintseditor.action.triggerParameterHints
⇧⌥F (Windows Shift+Alt+F, Linux Ctrl+Shift+I)Format Documenteditor.action.formatDocument
⌘K ⌘F (Windows, Linux Ctrl+K Ctrl+F)Format Selectioneditor.action.formatSelection
F12Go to Definitioneditor.action.revealDefinition
⌘K ⌘I (Windows, Linux Ctrl+K Ctrl+I)Show Hovereditor.action.showHover
⌥F12 (Windows Alt+F12, Linux Ctrl+Shift+F10)Peek Definitioneditor.action.peekDefinition
⌘K F12 (Windows, Linux Ctrl+K F12)Open Definition to the Sideeditor.action.revealDefinitionAside
⌘. (Windows, Linux Ctrl+.)Quick Fixeditor.action.quickFix
⇧F12 (Windows, Linux Shift+F12)Peek Referenceseditor.action.referenceSearch.trigger
F2Rename Symboleditor.action.rename
⇧⌘. (Windows Ctrl+Shift+., Linux Ctrl+Shift+<)Replace with Next Valueeditor.action.inPlaceReplace.down
⇧⌘, (Windows Ctrl+Shift+,, Linux Ctrl+<)Replace with Previous Valueeditor.action.inPlaceReplace.up
⌃⇧⌘→ (Windows, Linux Shift+Alt+Right)Expand AST Selectioneditor.action.smartSelect.expand
⌃⇧⌘← (Windows, Linux Shift+Alt+Left)Shrink AST Selectioneditor.action.smartSelect.shrink
⌘K ⌘X (Windows, Linux Ctrl+K Ctrl+X)Trim Trailing Whitespaceeditor.action.trimTrailingWhitespace
⌘K M (Windows, Linux Ctrl+K M)Change Language Modeworkbench.action.editor.changeLanguageMode

Navigation

KeyCommandCommand id
⌘T (Windows, Linux Ctrl+T)Show All Symbolsworkbench.action.showAllSymbols
⌃G (Windows, Linux Ctrl+G)Go to Line...workbench.action.gotoLine
⌘P (Windows, Linux Ctrl+P)Go to File..., Quick Openworkbench.action.quickOpen
⇧⌘O (Windows, Linux Ctrl+Shift+O)Go to Symbol...workbench.action.gotoSymbol
⇧⌘M (Windows, Linux Ctrl+Shift+M)Show Problemsworkbench.actions.view.problems
F8Go to Next Error or Warningeditor.action.marker.nextInFiles
⇧F8 (Windows, Linux Shift+F8)Go to Previous Error or Warningeditor.action.marker.prevInFiles
⇧⌘P (Windows, Linux Ctrl+Shift+P) or F1Show All Commandsworkbench.action.showCommands
⌃⇧Tab (Windows, Linux Ctrl+Shift+Tab)Navigate Editor Group Historyworkbench.action.openPreviousRecentlyUsedEditorInGroup
⌃- (Windows Alt+Left, Linux Ctrl+Alt+-)Go Backworkbench.action.navigateBack
⌃- (Windows Alt+Left, Linux Ctrl+Alt+-)Go back in Quick Inputworkbench.action.quickInputBack
⌃⇧- (Windows Alt+Right, Linux Ctrl+Shift+-)Go Forwardworkbench.action.navigateForward

Editor/Window Management

KeyCommandCommand id
⇧⌘N (Windows, Linux Ctrl+Shift+N)New Windowworkbench.action.newWindow
⇧⌘W (Windows, Linux Ctrl+W)Close Windowworkbench.action.closeWindow
⌘W (Windows Ctrl+F4, Linux Ctrl+W)Close Editorworkbench.action.closeActiveEditor
⌘K F (Windows, Linux Ctrl+K F)Close Folderworkbench.action.closeFolder
Cycle Between Editor Groupsworkbench.action.navigateEditorGroups
(Windows, Linux Ctrl+)Split Editorworkbench.action.splitEditor
⌘1 (Windows, Linux Ctrl+1)Focus into First Editor Groupworkbench.action.focusFirstEditorGroup
⌘2 (Windows, Linux Ctrl+2)Focus into Second Editor Groupworkbench.action.focusSecondEditorGroup
⌘3 (Windows, Linux Ctrl+3)Focus into Third Editor Groupworkbench.action.focusThirdEditorGroup
Focus into Editor Group on the Leftworkbench.action.focusPreviousGroup
Focus into Editor Group on the Rightworkbench.action.focusNextGroup
⌘K ⇧⌘← (Windows, Linux Ctrl+Shift+PageUp)Move Editor Leftworkbench.action.moveEditorLeftInGroup
⌘K ⇧⌘→ (Windows, Linux Ctrl+Shift+PageDown)Move Editor Rightworkbench.action.moveEditorRightInGroup
⌘K ← (Windows, Linux Ctrl+K Left)Move Active Editor Group Leftworkbench.action.moveActiveEditorGroupLeft
⌘K → (Windows, Linux Ctrl+K Right)Move Active Editor Group Rightworkbench.action.moveActiveEditorGroupRight
⌃⌘→ (Windows, Linux Ctrl+Alt+Right)Move Editor into Next Groupworkbench.action.moveEditorToNextGroup
⌃⌘← (Windows, Linux Ctrl+Alt+Left)Move Editor into Previous Groupworkbench.action.moveEditorToPreviousGroup

File Management

KeyCommandCommand id
⌘N (Windows, Linux Ctrl+N)New Fileworkbench.action.files.newUntitledFile
Ctrl+OOpen File...workbench.action.files.openFile
⌘S (Windows, Linux Ctrl+S)Saveworkbench.action.files.save
⌥⌘S (Windows Ctrl+K S, Linux )Save Allworkbench.action.files.saveAll
⇧⌘S (Windows, Linux Ctrl+Shift+S)Save As...workbench.action.files.saveAs
⌘W (Windows Ctrl+F4, Linux Ctrl+W)Closeworkbench.action.closeActiveEditor
⌥⌘T (Windows, Linux )Close Othersworkbench.action.closeOtherEditors
⌘K W (Windows, Linux Ctrl+K W)Close Groupworkbench.action.closeEditorsInGroup
Close Other Groupsworkbench.action.closeEditorsInOtherGroups
Close Group to Leftworkbench.action.closeEditorsToTheLeft
Close Group to Rightworkbench.action.closeEditorsToTheRight
⌘K ⌘W (Windows, Linux Ctrl+K Ctrl+W)Close Allworkbench.action.closeAllEditors
⇧⌘T (Windows, Linux Ctrl+Shift+T)Reopen Closed Editorworkbench.action.reopenClosedEditor
⌘K Enter (Windows, Linux Ctrl+K Enter)Keep Openworkbench.action.keepEditor
⌃Tab (Windows, Linux Ctrl+Tab)Open Nextworkbench.action.openNextRecentlyUsedEditorInGroup
⌃⇧Tab (Windows, Linux Ctrl+Shift+Tab)Open Previousworkbench.action.openPreviousRecentlyUsedEditorInGroup
⌘K P (Windows, Linux Ctrl+K P)Copy Path of Active Fileworkbench.action.files.copyPathOfActiveFile
⌘K R (Windows, Linux Ctrl+K R)Reveal Active File in Windowsworkbench.action.files.revealActiveFileInWindows
⌘K O (Windows, Linux Ctrl+K O)Show Opened File in New Windowworkbench.action.files.showOpenedFileInNewWindow
Compare Opened File Withworkbench.files.action.compareFileWith

Block Comment Visual Studio Shortcut

Display

KeyCommandCommand id
⌃⌘F (Windows, Linux F11)Toggle Full Screenworkbench.action.toggleFullScreen
⌘K Z (Windows, Linux Ctrl+K Z)Toggle Zen Modeworkbench.action.toggleZenMode
Escape EscapeLeave Zen Modeworkbench.action.exitZenMode
⌘= (Windows, Linux Ctrl+=)Zoom inworkbench.action.zoomIn
⌘- (Windows, Linux Ctrl+-)Zoom outworkbench.action.zoomOut
⌘Numpad0 (Windows, Linux Ctrl+Numpad0)Reset Zoomworkbench.action.zoomReset
⌘B (Windows, Linux Ctrl+B)Toggle Sidebar Visibilityworkbench.action.toggleSidebarVisibility
⇧⌘E (Windows, Linux Ctrl+Shift+E)Show Explorer / Toggle Focusworkbench.view.explorer
⇧⌘F (Windows, Linux Ctrl+Shift+F)Show Searchworkbench.view.search
⌃⇧G (Windows, Linux Ctrl+Shift+G)Show Source Controlworkbench.view.scm
⇧⌘D (Windows, Linux Ctrl+Shift+D)Show Debugworkbench.view.debug
⇧⌘X (Windows, Linux Ctrl+Shift+X)Show Extensionsworkbench.view.extensions
⇧⌘U (Windows Ctrl+Shift+U, Linux Ctrl+K Ctrl+H)Show Outputworkbench.action.output.toggleOutput
⌃Q (Windows Ctrl+Q, Linux )Quick Open Viewworkbench.action.quickOpenView
⇧⌘C (Windows, Linux Ctrl+Shift+C)Open New Command Promptworkbench.action.terminal.openNativeConsole
⇧⌘V (Windows, Linux Ctrl+Shift+V)Toggle Markdown Previewmarkdown.showPreview
⌘K V (Windows, Linux Ctrl+K V)Open Preview to the Sidemarkdown.showPreviewToSide
⌃` (Windows, Linux Ctrl+`)Toggle Integrated Terminalworkbench.action.terminal.toggleTerminal

Search

KeyCommandCommand id
⇧⌘F (Windows, Linux Ctrl+Shift+F)Show Searchworkbench.view.search
⇧⌘H (Windows, Linux Ctrl+Shift+H)Replace in Filesworkbench.action.replaceInFiles
⌥⌘C (Windows, Linux Alt+C)Toggle Match CasetoggleSearchCaseSensitive
⌥⌘W (Windows, Linux Alt+W)Toggle Match Whole WordtoggleSearchWholeWord
⌥⌘R (Windows, Linux Alt+R)Toggle Use Regular ExpressiontoggleSearchRegex
⇧⌘J (Windows, Linux Ctrl+Shift+J)Toggle Search Detailsworkbench.action.search.toggleQueryDetails
F4Focus Next Search Resultsearch.action.focusNextSearchResult
⇧F4 (Windows, Linux Shift+F4)Focus Previous Search Resultsearch.action.focusPreviousSearchResult
(Windows, Linux Down)Show Next Search Termhistory.showNext
(Windows, Linux Up)Show Previous Search Termhistory.showPrevious

Preferences

KeyCommandCommand id
⌘, (Windows, Linux Ctrl+,)Open Settingsworkbench.action.openSettings
Open Workspace Settingsworkbench.action.openWorkspaceSettings
⌘K ⌘S (Windows, Linux Ctrl+K Ctrl+S)Open Keyboard Shortcutsworkbench.action.openGlobalKeybindings
Open User Snippetsworkbench.action.openSnippets
⌘K ⌘T (Windows, Linux Ctrl+K Ctrl+T)Select Color Themeworkbench.action.selectTheme
Configure Display Languageworkbench.action.configureLocale

Debug

KeyCommandCommand id
F9Toggle Breakpointeditor.debug.action.toggleBreakpoint
F5Startworkbench.action.debug.start
F5Continueworkbench.action.debug.continue
⌃F5 (Windows, Linux Ctrl+F5)Start (without debugging)workbench.action.debug.run
F6Pauseworkbench.action.debug.pause
F11Step Intoworkbench.action.debug.stepInto
⇧F11 (Windows, Linux Shift+F11)Step Outworkbench.action.debug.stepOut
F10Step Overworkbench.action.debug.stepOver
⇧F5 (Windows, Linux Shift+F5)Stopworkbench.action.debug.stop
⌘K ⌘I (Windows, Linux Ctrl+K Ctrl+I)Show Hovereditor.debug.action.showDebugHover

Tasks

KeyCommandCommand id
⇧⌘B (Windows, Linux Ctrl+Shift+B)Run Build Taskworkbench.action.tasks.build
Run Test Taskworkbench.action.tasks.test

Extensions

KeyCommandCommand id
Install Extensionworkbench.extensions.action.installExtension
Show Installed Extensionsworkbench.extensions.action.showInstalledExtensions
Show Outdated Extensionsworkbench.extensions.action.listOutdatedExtensions
Show Recommended Extensionsworkbench.extensions.action.showRecommendedExtensions
Show Popular Extensionsworkbench.extensions.action.showPopularExtensions
Update All Extensionsworkbench.extensions.action.updateAllExtensions

Next steps

Now that you know about our Key binding support, what's next...

  • Language Support - Our Good, Better, Best language grid to see what you can expect
  • Debugging - This is where VS Code really shines
  • Node.js - End to end Node.js scenario with a sample app

Common questions

How can I find out what command is bound to a specific key?

In the Default Keyboard Shortcuts, open Quick Outline by pressing ⇧⌘O (Windows, Linux Ctrl+Shift+O)

How to add a key binding to an action? For example, add Ctrl+D to Delete Lines

Find a rule that triggers the action in the Default Keyboard Shortcuts and write a modified version of it in your keybindings.json file:

How can I add a key binding for only certain file types?

Use the editorLangId context key in your when clause:

I have modified my key bindings in keybindings.json, why don't they work?

The most common problem is a syntax error in the file. Otherwise, try removing the when clause or picking a different key. Unfortunately, at this point, it is a trial and error process.

9/4/2019

Coments are closed