Really useful VS Code key bindings and format on save

These are the key bindings I use on VS Code to do work more efficiently. Look for the Zen Mode key binding!

These are the key bindings I use on VS Code to do work more efficiently. If you haven't tried it yet, go try Zen Mode on VS Code (look for the key binding below).

Terminal

  • ctrl + ` - open/close the integrated terminal
  • ctrl + shift + ` - open a new integrated terminal
  • ctrl + PageUp/PageDown - switch terminal tabs (or file tabs if the terminal is closed)

Writing Code

  • ctrl + / - toggle line comment
  • ctrl + (shift) + enter - insert a new line (up) down the current line
  • shift + alt + up/down - copy line(s) up/down (i.e. select multiple lines to copy multiple lines)
  • alt + up/down - move line(s) up/down
  • ctrl + g - go to line
  • ctrl + shift + space - show parameter hints
  • ctrl + shift + o - go to symbol (i.e. go to a variable, a function, etc. in a file)
  • F2 - rename symbol (e.g. select a variable and rename other instance of that variable)
  • ctrl + shift + m - open/close problems tab (e.g. eslint errors)

Files

  • ctrl + w - close file
  • ctrl + p - go to file
  • ctrl + shift + e - open file explorer on the sidebar

Appearance

  • ctrl + k + t - change theme
  • ctrl + k z - toggle Zen mode (i.e. ctrl+k, release, then z, to toggle workspace focus mode)

General

  • ctrl + shift + p - open the command palette (e.g. type commands for anything in VS Code)
  • ctrl + b - open/close sidebar
  • ctrl + shift + x - open extension on the sidebar
  • ctrl + z - undo last action
  • ctrl + s - save file

Format on Save

Lastly, if you want to automatically format your files, you can add the following to the workspace settings. Open the command palette, ctrl + shift + p then go to "Workspace Settings (JSON)". This will only work if you have a formatter already installed like Prettier for JavaScript.

{
    "editor.formatOnSave": true
}