Skip to content

VS Code 👷🏼‍♂️👷🏼‍♀️

Shortcuts - General

Action Shortcut
Command Palette [Ctrl] + Shift + P
Command Palette (file search only) [Ctrl] + P
Refactor (across files) F2
Open/Close Terminal [Ctrl] + '
Select Item at Cursor [Ctrl] + D
Find Files [Ctrl] + P (win) / [CMD] + p (mac)
Cycle through last set of opened files [Ctrl] + [Tab]

Shortcuts - UI

Action Shortcut
Zen Mode [CMD] + K , Z
Show/Hide Terminal/Output Window [CMD] + j
Show/Hide sidebar [CMD] + b
Show Explorer in sidebar [CMD] + [Shift] + e
Show Debugger in sidebar [CMD] + [Shift] + b
Show Extensions in sidebar [CMD] + [Shift] + x
Show Source Control in sidebar [Ctrl] + [Shift] + g
Show/Hide tabs [CMD] + [Ctrl] + w

Shortcuts - Coding

Action Shortcut
Find symbols in code [CMD] + [Shift] + o
Jump to line [Ctrl] + g
Goto Definition F12
Peek Definition [Alt] + F12
Goto References [Shift] + F12
Find All References [Alt] + [Shift] + F12
Format Document [Alt] + [Shift] + F
Organise Imports [Alt] + [Shift] + O
Autocomplete [Ctrl] + Space
Quick Fix Menu [Ctrl] + .

Holding [Ctrl] or [Cmd] while hovering your mouse over your code will turn references, etc. into links you can click on.

Note: On an NVidia Windows machine [Alt]+F12 is mapped in nVidia geForce so might need remapping.

Code Folding

Action Shortcut
Fold All [Ctrl/CMD] + K, [Ctrl/CMD] + 0
Fold to level [Ctrl/CMD] + K, [Ctrl/CMD] + [1 - ?]
Unfold all [Ctrl/CMD] + K, [Ctrl/CMD] + J

Debugging

Action Shortcut
start/continue F5
stop debugging [Shift] + F5
step over F10
step in F11
step out [Shift] + 11
show hover window [Ctrl/CMD] + K, [Ctrl/CMD] + I
set/unset breakpoint on line F9

Other Notes

  • can use the command palette to open files
  • can create snippets (by language) to insert common code (type 'snip' into command palette)

When creating files, can specify folder as part of the filename e.g. mydir/main.cpp and code will create the folder if it doesn't already exist. (sometimes you need to refresh the project tree with the refresh icon to the right of it's name)

Right click on an item gives open to go to the definition or peek at it.


Stuff to go in settings.json

"editor.renderIndentGuides": false,

You can automate the organising of imports, etc.. by editting the settings.json file and adding

"editor.codeActionsOnSave": {
    "source.organizeImports": true
}

Turn off use of tabs when working with markdown and python...

    "[markdown]": {
        "editor.insertSpaces": true,
        "editor.useTabStops": false,
    }
    "[python]": {
        "editor.insertSpaces": true,
        "editor.useTabStops": false,
    },

Useful Palette Commands

  • Reload Window

Magnify Contents

To magnify the contents of the window (rather than the entire UI) add the following keyboard settings:-

  1. Code > Preferences > Keyboard Shortcuts
  2. This opens a GUI for keyboard shortcuts - click on the tab "Keyboard Shortcuts", and an icon with a file and arrow will appear (title - Open Keyboard Shortcuts JSON
  3. Copy paste the below JSON into the file and save
[
    {
        "key": "cmd+=",
        "command": "editor.action.fontZoomIn"
    },
    {
        "key": "cmd+-",
        "command": "editor.action.fontZoomOut"
    },
    {
        "key": "cmd+0",
        "command": "editor.action.fontZoomReset"
    }
]

Extension Shortcuts

Extension Action Shortcut
Markdown Preview Enhanced Open Preview Pane [CTRL] + K, V