VS Code Refactoring and Code Intelligence Shortcuts
Speed up code refactoring in VS Code with shortcuts for rename symbol, go to definition, peek definition, format document, and quick fixes.
Detailed Explanation
VS Code Refactoring Shortcuts
VS Code provides powerful code intelligence features powered by language servers. These shortcuts let you navigate and refactor code without leaving the keyboard.
Navigation
- Go to Definition (
F12) — jump to where a symbol is defined. Works for functions, classes, variables, and types. - Peek Definition (
⌥+F12/Alt+F12) — view the definition inline without leaving your current file. An inline editor appears below the cursor. - Go Back (
⌃+-/Alt+←) — return to your previous cursor position after jumping to a definition. - Go to Symbol (
⌘+Shift+O/Ctrl+Shift+O) — jump to any function, class, or variable in the current file by name.
Refactoring
- Rename Symbol (
F2) — rename a variable, function, or class across all files. This is a semantic rename, not a find-and-replace. - Format Document (
⌘+Shift+F/Ctrl+Shift+F) — auto-format the entire file using the configured formatter (Prettier, ESLint, etc.). - Quick Fix (
⌘+./Ctrl+.) — show available code actions like extracting a function, adding missing imports, or fixing lint errors. - Organize Imports — available via Command Palette. Removes unused imports and sorts them alphabetically.
Code Folding
- Fold Region (
⌘+⌥+[/Ctrl+Shift+[) — collapse the current code block - Unfold Region (
⌘+⌥+]/Ctrl+Shift+]) — expand a collapsed block - Fold All (
⌘+K ⌘+0/Ctrl+K Ctrl+0) — collapse everything for a high-level view
Trigger IntelliSense
- Trigger Suggestion (
⌘+Space/Ctrl+Space) — manually invoke autocomplete when it does not appear automatically - Parameter Hints (
⌘+Shift+Space/Ctrl+Shift+Space) — show function parameter documentation
These shortcuts work best with TypeScript, JavaScript, Python, Go, Rust, and any language that has a VS Code language server extension.
Use Case
Refactoring shortcuts are critical during code reviews, bug fixes, and feature development. Rename Symbol alone saves significant time compared to manual find-and-replace, because it understands scope and only renames the correct symbol. Teams that enforce code formatting via shortcuts maintain consistent code style without manual effort.