VS Code + Ctrl+Shift+S = Wat?!

Like many of you out there, I’ve been using Visual Studio (literally) ever since there was a Visual Studio (and Visual InterDev prior to that). One of the keyboard shortcuts that has been burned into the muscle memory of my left hand for years now is CTRL+SHIFT+S which is a common shortcut for “Save All”. I can’t claim that this keyboard shortcut has consistently mapped to “Save All” for the life of Visual Studio but it has definitely been around for quite a while (if not its entire life).

I also can’t claim that CTRL+SHIFT+S is a well-known universal key combination for “Save All”. However, taking a quick look at a few apps on my workstation (that supports multiple tabs/documents being open/edited), here’s what I found:

Application CTRL+SHIFT+S = “Save All”
Visual Studio 2015 YES
Notepad++ YES
MarkdownPad

YES

However, in Visual Studio Code (VS Code), out of the box CTRL+SHIFT+S maps to “Save As”! Now, to be fair, I did notice that Paint.NET also maps CTRL+SHIFT+S to “Save As”. That doesn’t mean that I agree with that mapping, however Smile

By now, it’s probably obvious what the answer is… simply remap the key combination to the appropriate action and move on with life. Well, you’re right! The purpose of this post is simply to familiarize someone new to VS Code with the ability to (re-)map keyboard shortcuts.

In Visual Studio you would need to open the Options dialog and traverse a vast hierarchical list of options to locate the keyboard mappings. However, in VS Code, Microsoft has made access to keyboard shortcuts front and center. To get to the current keyboard mappings, simply click on File->Preferences->Keyboard Shortcuts.

image

This will open two editor screens with the default key bindings being displayed (as read only) in the left editor pane and your custom key bindings in the right pane.

image

It is the right pane where you will create your custom key bindings.

To fix my pet peeve I will need to remap CTRL+SHIFT+S to “Save All”. To do this:

  1. While in the right pane, press CTRL+K CTRL+K. This will open a small dialog window and start a series of prompts.
  2. Press CTRL+SHIFT+S and press Enter.

    image

  3. Replace the highlighted “commandId” with the command for “Save All”. When you start typing over this command, VS Code will provide IntelliSense to help you locate the command you need. For example, start typing “SaveA…” and you’ll see the list of commands being filtered as you type.
    image
  4. Select “workbench.action.files.saveAll” and save your changes (e.g. press CTRL+S).

From now on VS Code will behave just like it should have out of the box (IMHO) when you press CTRL+SHIFT+S by saving all modified files.

As a bonus for the curious minded, scroll down toward the bottom of the left pane to see a list of other available commands that have not been mapped. You might find something in there that you would like to map to a key combination.

image

Happy mapping!

ContactUs.com

VS Code + Ctrl+Shift+S = Wat?!

by Jeff Bramwell time to read: 2 min
1