乐闻世界logo
搜索文章和话题

How do I skip a match when using Ctrl+D for multiple selections in Sublime Text 2?

1个答案

1

When editing code in Sublime Text 2, Ctrl+D is a powerful shortcut that selects the next occurrence of the currently selected word in the document. This is very useful for batch editing or searching for identical terms. However, in some cases, you may want to skip certain matches and select only specific ones you're interested in.

To skip certain matches when using Ctrl+D for multi-selection, follow these steps:

  1. Select the starting word – place the cursor on the word or double-click it to select it.
  2. Press Ctrl+D to select the next match – Sublime Text will automatically locate and select the next occurrence of the word in the document.
  3. If the next match is one you wish to skip – avoid pressing Ctrl+D. Instead, navigate to the next desired match using the arrow keys.
  4. Manually select the next desired match – click with the mouse or use keyboard shortcuts such as Shift + Arrow Keys.
  5. Press Ctrl+D again to continue selecting other matches – Sublime Text will search and select the next match from your current cursor position.

This method effectively helps you skip unwanted matches when needed, which is very useful for editing complex code or documents.

For example, if you're editing a JavaScript file and want to refactor the variable name data but wish to skip instances where it's an object property (e.g., response.data), you can select the first standalone data, then use Ctrl+D. When you encounter response.data, navigate past it using the arrow keys, and continue with Ctrl+D to find the next standalone data.

2024年7月22日 09:50 回复

你的答案