DEV Community

JessYT
JessYT

Posted on • Originally published at jessinvestment.com

VS Code Shortcuts and Settings That Cut Your Mouse Usage

VS Code Shortcuts and Settings That Cut Your Mouse Usage

If you drive VS Code through menu clicks alone, you end up repeating the same edit one line at a time. Learn just three things — multi-cursor, the Command Palette, and settings.json — and your hands leave the keyboard far less often. Every shortcut below is a default straight from the official VS Code docs (macOS shown, Windows·Linux in parentheses).

Why shortcuts are worth learning first

VS Code is built so the same task can be done through menus or through shortcuts. The problem with the menu route is that it sends your hand to the mouse and back to the keyboard again. Renaming a variable in ten places, fixing indentation, running a specific command — these repeat dozens of times a day. Moving that repetitive loop onto the keyboard is the whole point of learning shortcuts.

The three areas below have an especially good payoff-to-effort ratio: there are only a handful of shortcuts to memorize, but they apply almost everywhere.

What you want to do Mouse way Shortcut way
Edit the same word in several places at once Double-click each spot and retype, one by one Create multiple cursors and type once
Run a specific command (e.g. format a file) Dig through the menu tree Type part of its name in the Command Palette
Auto-format on every save Run format manually each time Add one line to settings.json

Multi-cursor — the same edit, all at once

Multi-cursor creates two or more cursors that all receive the same input simultaneously. When you have several similar lines, you can edit them all in one pass instead of fixing them line by line.

Adding cursors above and below

Use this when you want to type at the same position on multiple lines. ⌥⌘↓ (Ctrl+Alt+Down on Windows·Linux) adds a cursor on the line below, and ⌥⌘↑ (Ctrl+Alt+Up) adds one above. Cursors stack with each press, and everything you type afterwards goes to all of them.

Selecting the same word one match at a time

Put the cursor on a word and press ⌘D (Ctrl+D) to select it. Press again and the next occurrence of the same word is added to the selection. Because you pick matches one at a time, it's handy when you only want to change some occurrences of a name, not all of them.

Selecting every occurrence at once

To grab every occurrence at once, press ⇧⌘L (Ctrl+Shift+L). A cursor lands on every instance of the selected string in the file. Since the blast radius is wide, it's worth scanning the file afterwards to make sure you didn't change something you didn't intend to.

Column (box) selection

For text aligned vertically like a table, use column selection. With the mouse, hold Shift+Alt and drag; with the keyboard, combine the selection shortcuts (Shift + arrow keys) to grab a vertical block. You can then type into the same column of every line at once.

For example, with several similar lines like the ones below, putting a cursor on each line lets you prepend a declaration keyword or append a trailing semicolon in one go.

name  = "kim"
email = "kim@example.com"
role  = "admin"
// Add a cursor at the start of each line and type 'const ' once
// Add a cursor at the end of each line and append ';' once
Enter fullscreen mode Exit fullscreen mode

Command Palette — run things without digging through menus

Nearly every VS Code feature is registered as a command, and the Command Palette runs any of them by name. Open it with ⇧⌘P (Ctrl+Shift+P). No need to memorize the menu structure — typing a fragment like "format", "rename", or "git" narrows the candidates instantly.

The same input box switches modes depending on its prefix. Knowing this lets one box handle several kinds of navigation.

  • ⌘P (Ctrl+P) — jump to a file by name. The companion box to the Command Palette (⇧⌘P).
  • ⇧⌘O (Ctrl+Shift+O) — jump to a symbol (function·class, etc.) in the current file. This is the @ prefix mode of the same input box.
  • ⌃G (Ctrl+G) — go to a specific line number.
  • ? — type a question mark in the box to see a list of every command mode available right there.

The most common pattern: open ⇧⌘P, type part of a command name, hit Enter. For example, instead of hunting through menus for Format Document, typing just "format" in the palette brings it right up.

Folding and formatting — shortcuts for long files

When a file gets long, folding some blocks away makes it easier to read. Fold all with ⌘K ⌘0 (Ctrl+K Ctrl+0), unfold all with ⌘K ⌘J (Ctrl+K Ctrl+J), and toggle just the block at the cursor with ⌘K ⌘L (Ctrl+K Ctrl+L). These are two-step chords: press ⌘K, then the next key.

Code formatting is done with Format Document. The shortcut is ⇧⌥F (Shift+Alt+F on Windows, Ctrl+Shift+I on Linux), and it reformats the entire current file using the registered formatter's rules. One caveat: a formatter (extension) for that language has to be installed for it to work.

settings.json — configure once, save time every day

There are two ways into settings. The searchable UI opens with ⌘, (Ctrl+,); to edit the JSON file directly, run "Preferences: Open User Settings (JSON)" from the Command Palette. Anything you toggle in the UI ends up in the same JSON anyway, so keeping your go-to settings in JSON makes them easy to carry to a fresh machine.

Below are settings shown as examples in the official docs: format on save, auto-save after a delay, visible whitespace characters, and soft-wrapping long lines.

// settings.json (User)
{
  "editor.formatOnSave": true,
  "files.autoSave": "afterDelay",
  "editor.renderWhitespace": "all",
  "editor.wordWrap": "on"
}
Enter fullscreen mode Exit fullscreen mode

formatOnSave runs the formatter on every save to keep things tidy (again, a formatter must be installed). Setting autoSave to "afterDelay" saves your file automatically after a moment, no ⌘S required. renderWhitespace makes spaces and tabs visible, which helps catch mixed indentation.

Good to know upfront

Common gotchas when using these settings and shortcuts:

  • The shortcuts above are defaults. They can stop working if another extension or an OS shortcut conflicts — when that happens, run "Open Keyboard Shortcuts" from the Command Palette to check for collisions.
  • Format Document and formatOnSave only work with a formatter extension installed. Default formatters vary by language, so if formatting does nothing, check whether a formatter for that language is installed first.
  • Select-all shortcuts like ⇧⌘L cast a wide net and can change the same string in places you didn't intend. After a broad selection, review before applying.
  • With autoSave on, saves happen automatically — anything wired to save events (format·lint) may run more often than you expect.

What order to learn them in

Trying to memorize everything at once means nothing sticks. Start with the two highest-frequency ones — ⌘D (select same word) and ⇧⌘P (Command Palette) — for a few days, and once they're in muscle memory, add cursor-above/below and settings.json. Whenever you catch yourself doing something with the mouse, ask "is there a shortcut for this?" and search the Command Palette — the shortcuts for your most-used commands will start sticking on their own.

Getting started: Install from the official site, and open the full shortcut list via "Open Keyboard Shortcuts" in the Command Palette — it's searchable. It also shows exactly how each shortcut above is bound on your own keyboard layout.

Sources

This is an objective guide compiled from the official VS Code documentation, not a personal usage review. Shortcuts are macOS defaults and may differ by version, OS, and extension setup.

Originally published at jessinvestment.com


Original with full infographics and visual structure: https://jessinvestment.com/vs-code-shortcuts-and-settings-that-cut-your-mouse-usage/

Top comments (0)