VSCode keyboard shortcuts


I have just recently found the shortcut key to type in the “degree” symbol for temperature in VSCode. It is Shift + Alt + 8 (Mac). It’s handy for rules to specify temperatures e.g. 24|"°C"

I’m wondering if there’s a shortcut key to type in the MQTT transformation chaining (the intersect symbol?) in VSCode? So far I’ve been going to a sample web page (e.g. the mqtt binding doc), and copy pasting the symbol into my rules.

Are there any other handy keyboard shortcuts we should know?
I’ll list what I know:

Cmd+]   to indent
Cmt+[   to outdent
Cmd+F2  to 'refactor' ie. rename all instances of the same variable in the current file
CMD+P   to open the file search popup in order to jump to / open it -
        much faster than looking for that one file when you have a lot of files to work on
Cmd+/   to comment/uncomment

I’ll add more here when I think of some more.

Ctrl-K C/U to comment out/uncomment current line

That’s an OS X thing and not implemented by VSCode. You can type that combo in any other on the Mac and get the degree symbol. If you enter ctrl-cmd-space it will open a dialog where you can find emoji and symbols. Search for "union"v and you should find the symbol for MQTT.

On Windows you can type alt and the character coffee but I find it easier to use the character map.

I’m not sure how to do it in Linux it Chromebooks. I’m sure there is a way.

I’m not at a place where I can test these but from memory:

  • ctrl-/ to comment, ctrl-shift-t/ to uncomment. If it understands what type of file you have open it will use the right comment characters (e.g # for python)

  • ctrl-space: open the auto complete dialog

  • ctrl-tab to indent multiple highlighted lines

  • ctrl-shift-tab de-indent multiple selected lines

  • ctrl-shift-f: search all files in the workspace

  • ctrl-shift-t: reopen the most recently closed editor

  • ctrl-`: open the terminal

  • ctrl-shift-arrows: select by words instead of just characters. To navigate by words without selecting, omit the shift.

It should be noted that almost every one if these Key combos work almost universally. For example ctrl-space also works in Eclipse, Visual Studio, InteliJ, etc. Ctrl-shift-t will reopen the last closed tab in Chrome. Etc.

Personally, I am one is those strange guys who uses the Vim extension in VSCode so I’m sure there are plenty more key combos I might use but don’t because I use the Vim approach instead. I mostly do it because “:w” is still muscle memory for saving even after all these years.

Markus already mentioned CTRL+K+C and CTRL+K+U, but the shortcut I use the most after those is CTRL+SHIFT+P to bring up the Command Palette. Another handy one while searching, F3 is next and SHIFT+F3 is previous.

Not specific to VS Code, but…

CTRL+SHIFT+U+the extended ASCII code in hex (80-FF)+ENTER

The ones I use the most are superscript 2 (²): CTRL+SHIFT+U+B+2+ENTER
and degree symbol (°): CTRL+SHIFT+U+B+0+ENTER

We could of course add some UoM related units to the extension as snippets.

Vscode has a big palette of keyboard shortcuts that can be configured via an own menu.
You can see the existing ones and the available actions that have no shortcut set yet.

For example i have configured custom ones for opening and closing the terminal area to switch between a large editing area and a large console window.

And additionally you may follow @code on Twitter.
They retweet users who found nice shortcuts for their usecases recently.
I have found several useful shortcuts I didn’t even look for yet there. :slight_smile: