Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

VS Code Tricks You're Probably Wasting Time Without

· 6 min read · Home Tech

In this article
  1. Why These Tricks Matter More Than You Think
  2. The Command Palette: Your Swiss Army Knife
  3. Multi-Cursor Editing: Stop Repeating Yourself
  4. Quick File Navigation: Stop Clicking Through Tabs
  5. Integrated Terminal and Tasks: Don't Leave the Editor
  6. Code Formatting and Refactoring: Let the Editor Do the Work
  7. Find and Replace with Regex: When Simple Search Isn't Enough
  8. Common Problems and How to Avoid Them
  9. Frequently Asked Questions

If you're still reaching for the mouse to switch files, retype code, or scroll through long outputs, you're losing minutes every hour. Here are the built-in VS Code features that eliminate that friction, most of which you can start using today without installing anything.

Why These Tricks Matter More Than You Think

VS Code is the most popular code editor for a reason: it's fast, extensible, and free. But its default interface hides a lot of power behind keyboard shortcuts and command palette entries. The difference between an average user and a power user isn't raw typing speed—it's how few interruptions happen between thinking and writing. Every time you touch the mouse to click a file tab, scroll to find a function, or retype a variable name, you break your flow. These tricks remove those breaks.

Most of what follows works out of the box in the current stable release (as of 2024). No extensions required, though a few suggestions mention popular ones where they genuinely help.

The Command Palette: Your Swiss Army Knife

Press Ctrl+Shift+P (or Cmd+Shift+P on Mac) and you get a fuzzy-searchable list of every command in the editor. Type a few letters and hit Enter. This single shortcut replaces dozens of menu clicks. For example:

  • Type reindent to fix messy indentation in the current file.
  • Type toggle word wrap to switch wrapping without going into settings.
  • Type git sync to pull and push in one action.

You can also use it to run tasks, change the color theme, or open keyboard shortcut references. If you only learn one thing from this article, make it this.

Multi-Cursor Editing: Stop Repeating Yourself

Hold Alt and click anywhere to add a second cursor. Type once, and the same text appears at every cursor. This is the fastest way to rename a variable that appears in several places, add commas to multiple lines, or edit a list of similar items.

Even better: select a word, then press Ctrl+D (or Cmd+D) to add the next occurrence to your selection. Keep pressing it to select all matches, then type to replace them all at once. For a full-file rename, F2 on a symbol (like a function name) will rename it everywhere it's used, respecting scope—much safer than find-and-replace.

Quick File Navigation: Stop Clicking Through Tabs

Press Ctrl+P (or Cmd+P) to open the Quick Open panel. Type part of a filename and hit Enter. This is dramatically faster than hunting through the Explorer sidebar, especially in large projects.

From the same panel, you can:

  • Type @ followed by a symbol name to jump to a function or class in the current file.
  • Type : followed by a line number to jump to that line.
  • Type # to search across all files for a symbol name.

Combine these: Ctrl+P, type @, then the function name—you're there in under two seconds.

Integrated Terminal and Tasks: Don't Leave the Editor

Open the integrated terminal with Ctrl+` (backtick). You can run npm, git, Python, or any command without switching windows. The terminal is a full shell, so all your aliases and tools work.

For repeated commands (build, test, deploy), set up Tasks. Press Ctrl+Shift+P, type Tasks: Configure Task, and create a tasks.json file. For example, a simple npm build task looks like this:

{
  "version": "2.0.0",
  "tasks": [
    {
      "label": "Build",
      "type": "npm",
      "script": "build",
      "group": "build"
    }
  ]
}

Then run it with Ctrl+Shift+B. You can bind any task to any key combination.

Code Formatting and Refactoring: Let the Editor Do the Work

Press Shift+Alt+F (or Shift+Option+F) to format the entire file according to the installed formatter (like Prettier). Select a block and use Ctrl+K Ctrl+F to format just that selection.

For refactoring, select a piece of code, right-click, and look at the Refactor menu. VS Code can extract a selection into a new function, rename symbols across files, and even convert between arrow functions and regular functions in JavaScript. These actions are also available through the Command Palette, so you can trigger them without the mouse.

Find and Replace with Regex: When Simple Search Isn't Enough

The Find widget (Ctrl+F) has a .* icon to enable regular expressions. This turns a simple search into a powerful tool. For example, to swap the order of first and last name in a list of "First Last" lines, search for (\w+) (\w+) and replace with $2 $1.

You can also use regex in the multi-file search (Ctrl+Shift+F). This is invaluable for refactoring across a codebase. Just remember to test your regex on a small sample first—a bad pattern can silently corrupt many files.

Common Problems and How to Avoid Them

The most common mistake is trying to memorize all shortcuts at once. Instead, pick two or three from this list and force yourself to use them for a week. The Command Palette and multi-cursor are the highest return on investment.

Another issue: if multi-cursor doesn't work, check that you haven't accidentally disabled it in settings. Also, some laptop keyboards use Alt for special characters—try Ctrl+Alt instead. If formatting does nothing, you likely don't have a formatter installed for that language; install Prettier for JavaScript/CSS or the appropriate language-specific extension.

Finally, if the integrated terminal feels slow, check your shell settings—sometimes a slow startup script is the culprit, not VS Code.

Frequently Asked Questions

Do these tricks work on VS Code for the web (vscode.dev)?

Yes, the vast majority do. The Command Palette, multi-cursor, quick open, and find/replace all work identically in the browser version. The integrated terminal and some Git features may be limited or require a backend, but the core editing shortcuts are the same.

What's the best way to learn keyboard shortcuts?

Open the Keyboard Shortcuts editor with Ctrl+K Ctrl+S. You can search for any command, see its current binding, and change it. The most effective method is to look up a command you use frequently (like "delete line") and assign a memorable key. Also, the Command Palette shows the shortcut next to each command, so you'll absorb them naturally.

Is there a way to undo a multi-cursor action?

Yes. Press Ctrl+U (or Cmd+U) to undo the last cursor operation. This removes the last added cursor without undoing your typing. It's a lifesaver when you select too many occurrences.

Can I use these tricks with extensions like Vim?

Yes, but there can be conflicts. The Vim extension remaps many keys, so some shortcuts (like Ctrl+D) may not work as expected. You can usually configure the extension to avoid conflicts, or you can rely on Vim's own multi-cursor plugin if you prefer. For non-Vim users, the default shortcuts are fine.

Does this work on other editors like Sublime or Atom?

Many of these concepts are universal. Sublime Text has a similar Command Palette and multi-cursor. Atom (now discontinued) had them too. But the exact shortcuts differ, and VS Code's implementation is generally more polished and better integrated with its debugger and Git features.