Rename a VS Code symbol instead of replacing similar text
F2 starts a language-aware symbol rename when supported. Use it when you mean a code symbol, rather than every matching string.
- Scope
- Visual Studio Code · Current vendor documentation checked 3 November 2026; no running-app compatibility test is claimed.
- Keyboard and customization
- Documented Mac defaults; punctuation and function keys depend on keyboard layout and hardware.. User bindings, app versions, focused controls and installed extensions can change a command. Inspect the active app menu or its shortcut editor when a listed combination differs.
- Review basis
- Documentation reviewed 2026-11-03 by Codex — primary-documentation and editorial review; no hands-on runtime test. These bindings were not tested in a running app for this guide.
Start on the intended symbol
Place the cursor on the name you want to change and inspect the surrounding code before invoking rename. Language services can identify references more precisely than a plain text match, but the result still depends on the language, project configuration and provider. Do not assume every textual occurrence should represent the same symbol.
Review the proposed scope
Inspect any preview or resulting diff before accepting a broad rename as correct. References in generated files, unsupported languages or external systems may require separate attention. A successful command invocation is not the same as a complete project-wide migration, especially when names also appear in data or public interfaces.
Use textual tools for textual intent
If the goal is to change a repeated phrase in a note or a deliberately selected set of strings, Find/Replace or multi-cursors may be the better tool. Choose the operation based on meaning, then verify its scope. Function keys may require Fn on your keyboard, so inspect the menu or shortcut editor if F2 has a hardware action instead.
Documented commands for this workflow
Scroll the table sideways to see every column.
Sources and corrections
- Default keyboard shortcuts — Visual Studio Code — checked 2026-11-03
- Refactoring — Visual Studio Code — checked 2026-11-03
Found a mismatch? Email pashaseenainc@gmail.com with your app version, macOS version, keyboard layout and the command. Please leave personal document names out.
Keep going
Right there when you need it.
Keep a compact shortcut reference in your Mac’s menu bar.
Explore the native Mac app