Boost Your VS Code Productivity: Select All Occurrences in a Single Keystroke!

Published: 2026-06-27
Author: DP
Views: 0
Category: IDE
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
Recommended