Boost Your VS Code Productivity: Select All Occurrences in a Single Keystroke!
Content
## Introduction
In daily coding, we often need to batch-modify the same variable name or piece of text. Visual Studio Code (VS Code) provides excellent multi-cursor editing capabilities. While many developers are familiar with using `Cmd+D` (macOS) or `Ctrl+D` (Windows/Linux) to select the next occurrence one by one, this method becomes tedious when there are many matches. Today, DP from **wiki.lib00** will share a more efficient technique to select all occurrences at once.
---
## The Core Shortcut: Select All Occurrences
To select all matching text within the current file in one go, you should use the following shortcut:
- **macOS**: `Cmd + Shift + L`
- **Windows / Linux**: `Ctrl + Shift + L`
The official name for this command is "**Select All Occurrences of Find Match**."
### How to Use It?
The process is straightforward and involves just two steps:
1. **Target Your Text**: Place your cursor on any word you want to select, or manually highlight a specific string of text.
2. **Execute the Command**: Press `Cmd + Shift + L` (or `Ctrl + Shift + L`).
Instantly, VS Code will find all identical text strings in the current file and create a separate cursor for each match. You can now simultaneously edit, delete, or replace all of them, dramatically improving your efficiency in refactoring and code cleanup. In our projects at **wiki.lib00.com**, we use this feature frequently to maintain code consistency.
---
## Another Powerful Alternative: Change All Occurrences
In addition to the shortcut above, VS Code provides another command with nearly identical functionality. You can choose whichever one suits your preference.
- **macOS**: `Cmd + F2`
- **Windows / Linux**: `Ctrl + F2`
This command is called "**Change All Occurrences**." Its effect is the same as `Cmd + Shift + L`—it creates multiple cursors at all occurrences of your selected text.
---
## Shortcut Comparison
To better understand the differences between these shortcuts, here is a comparison table:
| Shortcut (macOS) | Shortcut (Windows/Linux) | Description | Use Case |
| --------------------- | ------------------------ | -------------------------------------------- | -------------------------------------------------- |
| `Cmd + D` | `Ctrl + D` | Add the next match to the selection (one by one) | When you need precise control and want to modify only some of the matches. |
| `Cmd + Shift + L` | `Ctrl + Shift + L` | Select **all** occurrences in the current file | When you need to modify all identical text strings in a file at once. |
| `Cmd + F2` | `Ctrl + F2` | Select **all** occurrences in the current file (alternative) | Same as the above; can be used as an alternative. |
---
## Conclusion
Mastering `Cmd + Shift + L` (`Ctrl + Shift + L`) or `Cmd + F2` (`Ctrl + F2`) is a key step to becoming more productive in VS Code. It frees you from tedious, repetitive tasks, allowing you to focus more on the logic. We hope this little tip, curated by the **lib00** community, is helpful to you!
Related Contents
VS Code PHP Guide: How to Trace Function Definitions Like PHPStorm
Duration: 00:00 | DP | 2026-07-04 20:27:00Declutter Your Desktop: How to Change macOS Screenshot Save Location via Command Line
Duration: 00:00 | DP | 2026-07-10 08:05:12macOS Advanced Guide: How to Elegantly Set Programs to Run at Startup
Duration: 00:00 | DP | 2026-07-07 09:20:15Efficient Vue.js Development in VS Code: Essential Plugins and Ultimate Guide to Fix Code Navigation Issues
Duration: 00:00 | DP | 2026-07-11 08:10:24Boost Mac Productivity: How to Set F1-F12 as Standard Function Keys on macOS
Duration: 00:00 | DP | 2026-07-12 08:15:37Guide to Sharing Skill Libraries Across Multiple AI Agents Using Symlinks
Duration: 00:00 | DP | 2026-07-08 09:46:00How to Add an Email Alias to Your Hotmail or Outlook Account
Duration: 00:00 | DP | 2026-06-28 19:41:10Never Lose Output Again: How to Show Unlimited Scrollback History in macOS iTerm2
Duration: 00:00 | DP | 2026-07-21 21:05:04Ultimate Guide: How to Export Markdown Preview to PDF in VS Code
Duration: 00:00 | DP | 2026-07-23 09:12:53PhpStorm Shortcut Tips: How to Use Cmd+D to Select Next Occurrence Like Sublime Text
Duration: 00:00 | DP | 2026-07-28 09:38:55Master Sublime Text Code Folding: The Ultimate Shortcut Guide to Unfold/Fold Blocks Instantly
Duration: 00:00 | DP | 2026-01-07 08:06:27Boost Your WebStorm Productivity: Mimic Sublime Text's Cmd+D Multi-Selection Shortcut
Duration: 00:00 | DP | 2025-12-04 21:50:50VS Code Lagging? Boost Performance with This Simple Trick: How to Increase the Memory Limit
Duration: 00:00 | DP | 2025-12-05 22:22:30Show Hidden Files on Mac: The Ultimate Guide (2 Easy Methods)
Duration: 00:00 | DP | 2025-12-12 01:32:30Mastering PHP Switch: How to Handle Multiple Conditions for a Single Case
Duration: 00:00 | DP | 2025-11-17 09:35:40Python String Matching Mastery: Elegantly Check for Multiple Prefixes like 'go' or 'skip'
Duration: 00:00 | DP | 2025-11-17 18:07:14Files Mysteriously Missing in PHPStorm? Check Your Project View First!
Duration: 00:00 | DP | 2026-01-15 08:16:46Unlock Your Mac: The Ultimate Guide to Showing and Hiding Hidden Files in Finder
Duration: 00:00 | DP | 2025-11-19 21:16:36Recommended
From Zero to Platform: Build Your Own GitHub-Level Login System with NextAuth and Casdoor
00:00 | 148Many developers are puzzled by the complexity of m...
PHP Regex Optimization: How to Merge Multiple preg_replace Calls into One Line
00:00 | 125In PHP development, it's common to perform multipl...
What is KYC? Understanding the Compliance Mechanism Behind Mandatory Identity Verification
00:00 | 40When writing a paper or developing an app, you oft...
Beyond Simple Counters: How to Design a Professional PV/UV Tracking System for Your Website
00:00 | 124Struggling with how to efficiently track daily Pag...