VS Code shortcut

This is from a VS Code blog

Opening and closing the sidebar

To close or open the sidebar, you can use command + b.

File Explorer

To open the file explorer, you can use command + shift + e.

Marketplace

To open the VS Code marketplace, you can use command + shift + x.

Switching workspaces

VS Code keeps tracks of folders you opened automatically. Each folder is a workspace. To switch between workspaces, use ctrl + r, then select the workspace you want.

Opening the terminal

VS Code has a built-in terminal that navigates to the project’s folder. To open the terminal, use command + `.

I tend to use the VS code terminal for simple one-off commands. When I need a dedicated terminal, I switch over to my iTerm. My shortcut to bring up iTerm is option + space.

Go to file

To go to a file, you use command + p, then type the name of the file you’re looking for. This should help you locate files quickly.

Go to line

To go to a line in the file, you use ctrl + g, then type a line number. Alternatively, you can also open the go to file menu with command + p first, then type :, then type your line number.

Go to symbol

In CSS, a symbol means a selector. In JavaScript, a symbol is variable.

To jump to a symbol in VS Code, you use command + r, then look for the symbol you want.

To jump to a symbol in your project workspace, you use command + shift + r.

The command palette

The command palette lets you execute tasks in VS code. To bring up the command palette, you use command + shift + p.

You can type any task you want to complete and VS Code will search for the task for you. If a keyboard shortcut exists, VS Code will show you the shortcut too.

Split Editor

When I code, I usually split the screen into two. You can bring up to three different editor views in VS Code.

To split the editor, you can use the split editor command. The original keyboard shortcut for split editor is 123. I switched it to command + option + 2.

To switch keyboard shortcuts, you can open up the keyboard shortcut editor by opening the command palette, type the keyboard shortcut, then click the pencil icon to the left of the command and enter your new command. Toggle editor group layout

You can also toggle between horizontal or vertical split layouts in VS Code. To do so, you use the toggle editor group command.

The original keyboard shortcut is command + option + 0. I switched it to command + option + 1.

Working with tabs

You can open a new tab by hitting command + t.

To switch between tabs, you use command + the tab number. 1 works for the leftmost tab; 2 for the second tab, and so on.

If you want to switch between tabs in different editors, use ctrl + the editor number. 1 works for the leftmost editor; 2 works for the second editor, and so on.

To close a tab, use command + w.

Select word

To select a word, use command + d. If you hit command + d more than once, you’ll add another occurrence of the same keyword to your selection.

To select all instances of a keyword in the same file, use ctrl + command + g. You can also use command + F2.

Folding and unfolding

To fold code, use command + opt + [. This command lets you hide code that you might not need.

To unfold code, use command + opt + ]

Move line upwards or downwards.

To move a line upwards or downwards, use opt + the up or down arrow key.

Split lines

To split a selection into multiple lines, first select multiple lines, then use command + opt + l.

Pageup / Pagedown

If you want to move up or down a document quickly, like through the good old pageup or pagedown shortcut in Windows, you can use fn + up or fn + down.

Jump to word

To jump to a word in VS Code, you need to install the Jumpy extension.

Once you’ve installed Jumpy, you can activate Jumpy’s “word mode” through the command line to enter the word jump mode.

In this mode, you can type the two letter characters that’s shown all over the editor to jump to the right word.

To exit jumpy’s word mode, you can type a non a-z character like space or enter.

I set the Jumpy’s word mode keyboard shortcut to command + j since J stands for jump.

Expand Region

The Expand region shortcut can only be used if you have installed the Expand Region extension. It should have been in the last video, but I completely forgot about it.

Expand region lets you select a word, expand the selection upwards to the containing brackets (or tags), then another level of brackets, and so on.

To expand upwards, I set the keyboard shortcut to command + option + up.

To undo the expansion, I set the keyboard shortcut to command + option + down.