Skip to content

customize shortcuts

Carlos Robles edited this page Feb 21, 2026 · 13 revisions

Customize Keyboard Shortcuts

The MSSQL extension supports two different mechanisms for keyboard shortcuts:

  • VS Code keybindings (keybindings.json) — for Command Palette commands such as Execute Query, Connect, and Disconnect. These are standard VS Code keybindings that you configure through the Keyboard Shortcuts editor or keybindings.json.
  • Result view shortcuts (mssql.shortcuts in settings.json) — for actions inside the query results pane such as navigating grids, copying data, and saving results. These use the extension's own shortcut system and are configured as an extension setting.

Companion Extension: MSSQL Database Management Keymap

If you're coming from SQL Server Management Studio (SSMS) or Azure Data Studio, install the MSSQL Database Management Keymap companion extension to get familiar shortcuts out of the box.

MSSQL Database Management Keymap extension in VS Code

The extension provides the following key bindings:

Function Windows / Linux macOS
Run query F5 F5
Run current statement Ctrl+F5 Cmd+F5
Open new SQL query editor Ctrl+N Cmd+N
Show query results pane Win+Shift+R Cmd+Shift+R
Show connection list Ctrl+Shift+D Cmd+Shift+D
Show estimated plan Ctrl+L Cmd+L
Toggle actual plan Ctrl+M Cmd+M
Cancel running query Alt+PauseBreak Option+PauseBreak

Note: This keymap does not include user-customized key bindings from Azure Data Studio. Custom key bindings need to be configured manually in the MSSQL keyboard preferences settings, accessible from the Command Palette. This extension overrides some default VS Code shortcuts for database management scenarios.

You can install this extension from the migration dialog when transitioning from Azure Data Studio, or directly from the Visual Studio Code Marketplace.

Customizing VS Code Keybindings

To customize any MSSQL command shortcut:

  1. Open the Keyboard Shortcuts editor: Cmd+K Cmd+S (macOS) or Ctrl+K Ctrl+S (Windows/Linux).
  2. Search for the command name (e.g. mssql.newQuery).
  3. Click the pencil icon next to the command and press the new key combination.
  4. Press Enter to confirm.

Alternatively, you can edit keybindings.json directly (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux > Preferences: Open Keyboard Shortcuts (JSON)):

[
  {
    "key": "ctrl+shift+n",
    "command": "mssql.newQuery",
    "when": "editorTextFocus && editorLangId == 'sql'"
  }
]

Note: You may override the shortcut for another command. Choose a keybinding that doesn't conflict with existing shortcuts. You can check for conflicts in the Keyboard Shortcuts editor.

MSSQL Extension Commands

The extension provides several commands accessible from the Command Palette (Cmd+Shift+P on macOS, Ctrl+Shift+P on Windows/Linux). Here are the most commonly used commands and their default shortcuts:

Command Description Windows/Linux macOS
MS SQL: Connect Connect to a SQL Server, Azure SQL, or SQL database in Fabric Ctrl+Shift+C Cmd+Shift+C
MS SQL: Disconnect Disconnect the current editor session Ctrl+Shift+D Cmd+Shift+D
MS SQL: Focus on Object Explorer Open the SQL Server Object Explorer view Ctrl+Alt+D Cmd+Alt+D
MS SQL: Execute Query Run a query for the current active SQL document Ctrl+Shift+E Cmd+Shift+E
MS SQL: Run Current Statement Execute only the T-SQL statement under the cursor
MS SQL: Cancel Query Cancel the query execution in progress
MS SQL: Use Database Switch to another database on the same server
MS SQL: New Query Open a new SQL query file
MS SQL: Manage Connection Profiles Create, edit, or remove connection profiles
MS SQL: Create Container Group Set up a new SQL Server container locally
MS SQL: Show Estimated Execution Plan View the estimated query execution plan

Result View Shortcuts

Unlike the VS Code keybindings above, result view shortcuts are configured through the mssql.shortcuts extension setting in settings.json (not keybindings.json). These shortcuts apply only within the query results pane.

When customizing these shortcuts, use ctrlcmd to represent both Ctrl on Windows/Linux and Cmd on macOS (e.g. ctrlcmd+c maps to Ctrl+C on Windows/Linux and Cmd+C on macOS).

Default Configuration

{
  "mssql.shortcuts": {
    // Query Results navigation
    "event.queryResults.switchToResultsTab": "ctrl+alt+R",
    "event.queryResults.switchToMessagesTab": "ctrl+alt+Y",
    "event.queryResults.switchToQueryPlanTab": "ctrl+alt+E",
    "event.queryResults.prevGrid": "ctrlcmd+up",
    "event.queryResults.nextGrid": "ctrlcmd+down",
    "event.queryResults.switchToTextView": "",
    "event.queryResults.maximizeGrid": "",
    "event.queryResults.saveAsJSON": "",
    "event.queryResults.saveAsCSV": "",
    "event.queryResults.saveAsExcel": "",
    "event.queryResults.saveAsInsert": "",

    // Result Grid actions
    "event.resultGrid.copySelection": "ctrlcmd+c",
    "event.resultGrid.copyWithHeaders": "",
    "event.resultGrid.copyAllHeaders": "",
    "event.resultGrid.selectAll": "ctrlcmd+a",
    "event.resultGrid.copyAsCSV": "",
    "event.resultGrid.copyAsJSON": "",
    "event.resultGrid.copyAsInsert": "",
    "event.resultGrid.copyAsInClause": "",
    "event.resultGrid.changeColumnWidth": "alt+shift+s",
    "event.resultGrid.expandSelectionLeft": "shift+left",
    "event.resultGrid.expandSelectionRight": "shift+right",
    "event.resultGrid.expandSelectionUp": "shift+up",
    "event.resultGrid.expandSelectionDown": "shift+down",
    "event.resultGrid.openColumnMenu": "f3",
    "event.resultGrid.openFilterMenu": "",
    "event.resultGrid.moveToRowStart": "ctrlcmd+left",
    "event.resultGrid.moveToRowEnd": "ctrlcmd+right",
    "event.resultGrid.selectColumn": "ctrl+space",
    "event.resultGrid.selectRow": "shift+space",
    "event.resultGrid.toggleSort": "alt+shift+o"
  }
}

Shortcut Reference

Query Results Shortcuts

Shortcut Event Default Binding Description
event.queryResults.switchToResultsTab Ctrl+Alt+R Switch to the Results tab
event.queryResults.switchToMessagesTab Ctrl+Alt+Y Switch to the Messages tab
event.queryResults.switchToQueryPlanTab Ctrl+Alt+E Switch to the Query Plan tab
event.queryResults.prevGrid Ctrl/Cmd+Up Navigate to the previous result grid
event.queryResults.nextGrid Ctrl/Cmd+Down Navigate to the next result grid
event.queryResults.switchToTextView Switch results to text view
event.queryResults.maximizeGrid Maximize/minimize the current grid
event.queryResults.saveAsJSON Save results as JSON
event.queryResults.saveAsCSV Save results as CSV
event.queryResults.saveAsExcel Save results as Excel
event.queryResults.saveAsInsert Save results as INSERT statements

Result Grid Shortcuts

Shortcut Event Default Binding Description
event.resultGrid.copySelection Ctrl/Cmd+C Copy the current selection
event.resultGrid.copyWithHeaders Copy selection with column headers
event.resultGrid.copyAllHeaders Copy all column headers
event.resultGrid.selectAll Ctrl/Cmd+A Select all data in the active grid
event.resultGrid.copyAsCSV Copy selection as CSV
event.resultGrid.copyAsJSON Copy selection as JSON
event.resultGrid.copyAsInsert Copy selection as INSERT statements
event.resultGrid.copyAsInClause Copy selection as an IN clause
event.resultGrid.changeColumnWidth Alt+Shift+S Adjust column width
event.resultGrid.expandSelectionLeft Shift+Left Expand selection to the left
event.resultGrid.expandSelectionRight Shift+Right Expand selection to the right
event.resultGrid.expandSelectionUp Shift+Up Expand selection upward
event.resultGrid.expandSelectionDown Shift+Down Expand selection downward
event.resultGrid.openColumnMenu F3 Open the column context menu
event.resultGrid.openFilterMenu Open the filter menu
event.resultGrid.moveToRowStart Ctrl/Cmd+Left Move to the start of the row
event.resultGrid.moveToRowEnd Ctrl/Cmd+Right Move to the end of the row
event.resultGrid.selectColumn Ctrl+Space Select the entire column
event.resultGrid.selectRow Shift+Space Select the entire row
event.resultGrid.toggleSort Alt+Shift+O Toggle sort on the current column

Related Pages

Clone this wiki locally