Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Visual Studio - keyboard shortcut to move caret/cursor to start or end of selection

Years ago I read about a visual studio shortcut which, if you had a selection, would move the caret/cursor to the start or the end of the selection.

I've tried searching for it, but can't for the life of me find it again.

In the image below, the text is selected and the caret is at the end, (highlighted pink). This shortcut would move the caret to the start of the selection (highlighted yellow).

vs selection caret move

Does anyone know what this shortcut is?

like image 320
GarethD Avatar asked Aug 10 '12 09:08

GarethD


1 Answers

I'm pretty sure that this the command called Edit.SwapAnchor. The documentation says that this command:

Swaps the anchor and end points of the current selection.

The keyboard shortcut probably depends on your IDE configuration (i.e., which language you indicated that you primarily develop in on first launch), but in mine it is mapped to Ctrl+R, Ctrl+P. That's the default for C++ developers, matching the default shortcuts for VC++ 6.

Edit:
Indeed, this is the one you're looking for. According to this post on the VS Tips & Tricks Blog, the keyboard shortcut is Ctrl+K, Ctrl+A.

And back in VC++ 2 it was mapped to Ctrl+Shift+X.   :-)

I'd open up Tools -> Options -> Environment -> Keyboard, type in "swapanchor" in the search box, and see what it's mapped to in your environment. If you use it frequently, change it to something memorable.

like image 120
Cody Gray Avatar answered Oct 20 '22 14:10

Cody Gray