Tryer
Tryer

Reputation: 4050

Visual Studio IDE: go to previous match in multi caret/cursor

Consider the following setup:

I have:

Test 1

T|est 2

Test 3

where | is the current cursor position. Application of Shft+Alt+. first highlights Test of Test 2. Subsequent application of Shft+Alt+. takes one to Test of Test 3. Is there a way to reverse this direction of movement and go from Test of Test 2 to Test of Test 1?

The command Edit.InsertNextMatchingCaret is default mapped to Shft+Alt+. There does not seem to be a command Edit.InsertPreviousMatchingCaret.

See gif below for visual description of the issue:

enter image description here

Upvotes: 2

Views: 219

Answers (1)

41686d6564
41686d6564

Reputation: 19641

Unfortunately, AFAIK, there's no out-of-the-box way to achieve this using keyboard shortcuts. Moving the caret works only in one direction in muti-caret editing. To select the previous match, you may use one of two options:

  • Option 1: Select the match manually using keyboard and mouse:

    Press Ctrl+Alt and then use the mouse to manually select the previous match (e.g., double click on the "Test" word in the "Test 1" line).

  • Option 2: If you want to rely on hotkeys only, you may use the following workaround:

    1. Press Shift+Alt+. to select the next match.
    2. Press Shift+Alt+/ to move the caret/selection to the following match.
    3. Repeat step #2 until you get to to the desired match.

    Here's a demo:

    enter image description here

Upvotes: 1

Related Questions