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
Master 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:36One-Click Code Cleanup: The Ultimate Guide to PhpStorm's Reformat Code Shortcut
Duration: 00:00 | DP | 2026-02-03 09:34:00Say Goodbye to Clutter: Master Sublime Text Code Folding with These Essential Shortcuts
Duration: 00:00 | DP | 2025-11-24 03:35:20The Dynamic `match` Trap in PHP: Why You Can't Generate Arms from an Array
Duration: 00:00 | DP | 2025-12-21 18:33:20From Repetitive to Reusable: Elegantly Refactoring Your JavaScript Markdown Renderer
Duration: 00:00 | DP | 2025-11-26 15:16:16From <script> Chaos to ES6 Clarity: Is Migrating to Modules Worth The Effort?
Duration: 00:00 | DP | 2025-11-11 08:16:46The Ultimate PHP Logging Guide: From a Messy Function to an Elegant Static Logger Class
Duration: 00:00 | DP | 2026-01-22 08:25:48Unlock Your IDE's Full Potential: A Deep Dive into PHPDoc for Flawless PHP Autocompletion
Duration: 00:00 | DP | 2025-11-13 21:27:00PHP Stuck on Loading After Enabling Xdebug? Don't Panic, It Might Be Working Perfectly!
Duration: 00:00 | DP | 2025-11-15 07:03:00PhpStorm Bookmark Shortcut Mystery: F11 or F3? The Definitive Answer!
Duration: 00:00 | DP | 2026-02-07 10:58:25The PHP Static Property Trap: Why You Cannot Initialize With a Function Call
Duration: 00:00 | DP | 2026-02-11 12:22:51Recommended
Master Your PHP CLI: 3 Quick Ways to Check for pdo_pgsql Installation
00:00 | 87When developing with PHP and PostgreSQL, ensuring ...
Why Encode Hashes with Base64/Base16 After MD5? A Deep Dive into Hashing vs. Encoding
00:00 | 151Many developers are familiar with hashing algorith...
MP3 vs. AAC/M4A: The Ultimate Audio Format Showdown—Who Is the King of Compatibility?
00:00 | 123In the world of digital audio, MP3 and AAC are two...
How Do You Pronounce Nginx? The Official Guide to Saying It Right: 'engine x'
00:00 | 147Struggling with the correct pronunciation of Nginx...