avatarBrandon Burrus

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

2072

Abstract

  • Cmd + E</code> : Similar to #3, except this shortcut will specifically toggle the Explorer every time. Once the Explorer is focused, you can use <code>J</code> and <code>K</code> to move the cursor up and down, <code>O</code> will open and close folders, and <code>/</code> will activate the Explorer-specific search filter.</p><h2 id="25e5">7. Global Find</h2><p id="3d69"><code>Shift + Cmd + F</code> : Also similar to #3, but this one works for the Global Find sidebar panel.</p><h2 id="c1a8">8. Focus Debugger</h2><p id="f154"><code>Shift + Cmd + D</code> : Another #3, except this one is for the Debugger sidebar. By default, VSCode binds most of the top-keyboard function keys to Debugger actions (e.g.: <code>F5</code> to start, <code>Shift + F5</code> to stop, <code>F9</code> to create a breakpoint), but I highly recommend changing these, as the function keys can be awkward to reach sometimes.</p><h2 id="9741">9. Focus Git</h2><p id="e681"><code>Shift + Ctrl+ G</code> : And one more #3, but this one is for Git. When you focus the Git sidebar, VSCode will put your cursor into the commit message field, so you can quickly commit any changes you have staged using <code>Cmd + Enter</code>. (By default, VSCode doesn’t have a shortcut to stage changes, I have mine bound to <code>Shift + Cmd + A</code> to <i>Stage All Changes</i>, and <code>Shift + Cmd + S</code> changed to <i>Stage Current File</i>)</p><h2 id="04f6">10. Move current line up or down</h2><p id="48d8"><code>Opt + Up</code> / <code>Opt + Down</code> : Easily move the line that the cursor is currently at up or down. This also works if multiple lines are selected as well.</p><h2 id="5e3b">11. Copy current line up or down</h2><p id="1016"><code>Shift + Opt + Up</code> / <code>Shift + Opt + Down</code> : Works exactly like #10, except it will copy lines instead of moving them.</p><h2 id="4e7a">12. Focus/Split Editor</h2><p id="c4f5"><code>Cmd + [1-9]</code> and <code>Cmd + </code> : Using <code>Cmd</code> with any number will focus on that specific editor number. For example: <code>C

Options

md + 2</code> will focus on the second editor, and if that specific editor window isn’t open, it will open an empty editor for you. If you want to split the current file into a second editor window, that’s what <code>Cmd + </code> does.</p><h2 id="5538">13. Close Current Editor</h2><p id="f1d5"><code>Cmd + W</code> : Closes the current editor that is currently focused. If you have the <code>workbench.editor.closeEmptyGroups</code> setting turned off, VSCode will leave an empty editor open for you (which <code>Cmd + W</code> will also close).</p><h2 id="3d80">14. Show Suggestion</h2><p id="4819"><code>Ctrl + Space</code> : Forcing Intellisense to open can come in really useful, especially when trying to find specific settings while editing <code>settings.json</code>.</p><h2 id="d349">15. Comment Selection</h2><p id="25dd"><code>Cmd + /</code> : Straightford, will comment out either the current selection or the line the cursor is currently on. This also works in reverse, in that it will also uncomment as well.</p><h2 id="46dd">Honorable Mention: Open Shortcuts</h2><p id="42ee"><code>Cmd + K + Cmd + S</code> : Opens the menu for changing Visual Studio Code’s default shortcuts. Any time you want to set a new shortcut or change an awkward one, this menu will quickly become your friend.</p><p id="a24a">Once you start to make an effort to learn the various shortcuts provided by VSCode, you’ll quickly realize just how much of your workflow can be easily achieved using a couple of key taps. It’s not to say that you’ll completely stop using your mouse altogether (although that is totally an option using the <a href="https://marketplace.visualstudio.com/items?itemName=vscodevim.vim">Vim</a> extension), but that now you’ll no longer be so reliant on using it anymore.</p><p id="f9d8">If you’d like a more complete reference/cheatsheet for all of the common VSCode shortcuts, check out the <a href="https://code.visualstudio.com/shortcuts/keyboard-shortcuts-macos.pdf">official guide</a>!</p><p id="7e9d">Good luck, and happy coding!</p></article></body>

15 Visual Studio Code Shortcuts You Should Know

Photo by Troy Chen on Unsplash

All of my articles are now available for free here, without the need for a subscription to Medium!

Mastering your keyboard can save you hours upon hours of time every week. Whether you’re working on that important project or trying to meet a deadline, knowing your shortcuts can be a massive difference maker. For Visual Studio Code, these are the essential shortcuts that everyone should know.

1. Open Command Palette

Shift + Cmd + P : The command palette will quickly become your best friend as you learn various shortcuts. If you ever forget a shortcut, simply open the command palette, and search for what you’re trying to do.

2. Find in current File

Cmd + F : Instantly find whatever you’re looking for in the current file you’re in. Pressing Alt at the same time will open the Find & Replace, and pressing Enter will move your cursor to the next occurrence of the current search.

3. Toggle Sidebar

Cmd + B : Straightford, quickly show and hide the sidebar.

4. Toggle Panel

Cmd + J : Quick show and hide the bottom panel, this includes the Terminal, Output, Problems, and Debug Console.

5. Find a File

Cmd + P : Quickly search for a specific file in the current workspace. This one works really well in conjunction when opening and using the split editor.

6. Focus Explorer

Shift + Cmd + E : Similar to #3, except this shortcut will specifically toggle the Explorer every time. Once the Explorer is focused, you can use J and K to move the cursor up and down, O will open and close folders, and / will activate the Explorer-specific search filter.

7. Global Find

Shift + Cmd + F : Also similar to #3, but this one works for the Global Find sidebar panel.

8. Focus Debugger

Shift + Cmd + D : Another #3, except this one is for the Debugger sidebar. By default, VSCode binds most of the top-keyboard function keys to Debugger actions (e.g.: F5 to start, Shift + F5 to stop, F9 to create a breakpoint), but I highly recommend changing these, as the function keys can be awkward to reach sometimes.

9. Focus Git

Shift + Ctrl+ G : And one more #3, but this one is for Git. When you focus the Git sidebar, VSCode will put your cursor into the commit message field, so you can quickly commit any changes you have staged using Cmd + Enter. (By default, VSCode doesn’t have a shortcut to stage changes, I have mine bound to Shift + Cmd + A to Stage All Changes, and Shift + Cmd + S changed to Stage Current File)

10. Move current line up or down

Opt + Up / Opt + Down : Easily move the line that the cursor is currently at up or down. This also works if multiple lines are selected as well.

11. Copy current line up or down

Shift + Opt + Up / Shift + Opt + Down : Works exactly like #10, except it will copy lines instead of moving them.

12. Focus/Split Editor

Cmd + [1-9] and Cmd + \ : Using Cmd with any number will focus on that specific editor number. For example: Cmd + 2 will focus on the second editor, and if that specific editor window isn’t open, it will open an empty editor for you. If you want to split the current file into a second editor window, that’s what Cmd + \ does.

13. Close Current Editor

Cmd + W : Closes the current editor that is currently focused. If you have the workbench.editor.closeEmptyGroups setting turned off, VSCode will leave an empty editor open for you (which Cmd + W will also close).

14. Show Suggestion

Ctrl + Space : Forcing Intellisense to open can come in really useful, especially when trying to find specific settings while editing settings.json.

15. Comment Selection

Cmd + / : Straightford, will comment out either the current selection or the line the cursor is currently on. This also works in reverse, in that it will also uncomment as well.

Honorable Mention: Open Shortcuts

Cmd + K + Cmd + S : Opens the menu for changing Visual Studio Code’s default shortcuts. Any time you want to set a new shortcut or change an awkward one, this menu will quickly become your friend.

Once you start to make an effort to learn the various shortcuts provided by VSCode, you’ll quickly realize just how much of your workflow can be easily achieved using a couple of key taps. It’s not to say that you’ll completely stop using your mouse altogether (although that is totally an option using the Vim extension), but that now you’ll no longer be so reliant on using it anymore.

If you’d like a more complete reference/cheatsheet for all of the common VSCode shortcuts, check out the official guide!

Good luck, and happy coding!

Web Development
Visual Studio Code
Productivity
Shortcuts
Keyboard Shortcuts
Recommended from ReadMedium