VS Code Keyboard Shortcuts (macOS)

The only Visual Studio Code keyboard shortcuts you’ll ever need.

Jordan Carroll
4 min readJan 27, 2021
Image Copyright © 2021 Apple Inc. All rights reserved.

While it may be annoying to memorize keyboard shortcuts, the time you invest learning them pays dividends in the long run. Once you know these shortcuts, you’ll be a much faster developer. They help you complete coding exams on time, work through projects efficiently, and stand out from the pack when you’re interviewing for jobs. VS Code offers over 100 keyboard shortcuts, but a lot of them don’t get used very often, so I’ve collected a small handful that come in handy all the time. I’ve divided them into various categories by the purpose they serve. FYI, the shortcuts below are for macOS, not for Microsoft, Linux, or other operating systems.

It can be overwhelming to even think about learning keyboard shortcuts, so you might find it helpful to learn one per day. Another strategy you might consider is writing them all on Post-it Notes then placing the notes around your computer so you can quickly refer to them whenever you’d like. Before you know it, you’ll be using these shortcuts all the time.

Highlighting Code

  • Shift Command L
    Highlights every occurrence of an item (word, class name, instance variable, etc.) in an open file. Once every occurrence is highlighted, you can edit, delete, etc. them all at the same time.
  • Shift or Shift
    Highlights one character (letter, punctuation mark, etc.) at a time to the right or left.
  • Shift Command or Shift Command
    Highlights an entire line of code to the right or left of your cursor.
  • Shift or Shift
    Highlights an entire line of code below or above the line your cursor is on.
  • Command D
    Highlights every occurrence of an item (word, class name, instance variable, etc.) in a file one by one.
  • Command U
    Un-highlights a single item (word, class name, instance variable, etc.) after you’ve highlighted it using Command D.

Cursor Movement

  • Option or Option
    Moves your cursor to the next item (word, class name, instance variable etc.) to the right or left, instead of moving only one character at a time.
  • Command or Command
    Moves your cursor to the top or the bottom of the file.
  • Command or Command
    Moves your cursor to the end of a given line or the beginning of a given line.

Copy and Cut

  • Command C
    Copies an entire line of code without highlighting it. You can click anywhere on the line of code and this command will work.
  • Command X
    Deletes an entire line of code without highlighting it. You can click anywhere on the line of code and this command will work.

Indentation

  • Command ]
    Indents a line of code. You can click anywhere on the line of code and this command will work.
  • Command [
    Outdents (un-indents) a line of code. You can click anywhere on the line of code and this command will work.

Display

  • Option Z
    Toggles word wrap. This is a fancy way of saying that this command modifies the way that your code is displayed so that it is all visible within the editor window and so that none of it spills over the side.
  • Command W
    Closes the editor window of whichever file is open.
  • Command \
    This command splits the editor window into two editor windows of the same file.
  • Command K Z
    Turns zen mode on or off. Zen mode is a more streamlined way of viewing whichever code you’re working on.
  • Command B
    Closes or opens the side bar (the bar that shows your project’s folders, files, etc.).
  • Control `
    Opens the Visual Studio Code terminal. Make sure that you don’t use (the apostrophe) for this command. It has to be ` (the backtick).
  • Command Shift T
    Opens an editor window that you just closed. This comes in handy if you closed a window then realize you still need it.
  • Control Enter
    If you click on a file in the side bar then use this command, the file will open on the right side of your editor window and the editor window will be in split screen.
  • Control Command F
    Turns full screen mode on or off.

Redo

  • Shift Command Z
    Redo after you undo something. This comes in handy when you’ve used command z to undo something, but then you realize you didn’t actually want to undo it.

Commenting

  • Command /
    Comments out a line or un-comments out a line.

Searching

  • Command Shift F
    Helps you find every occurrence of an item (letter, word, punctuation, etc.) in your entire project.

Moving Code

  • Option or Option
    Moves a line of code up or down one line.

--

--