22
votes

There is a shortcut Ctrl + Shift + W to select the entire word at the current cursor position.

Is there a similar shortcut that keeps expanding the selected region every time I apply it?

I mean, is there a shortcut which

  • selects the word when applied once (same as Ctrl + Shift + W) and
  • selects the entire line when applied twice in a row and
  • selects the entire block when applied three times etc.,

i.e. keeps expanding the selected region step by step?

I remember seeing such a shortcut, but I don't remember whether it was for Visual Studio or some other editor.

7

7 Answers

16
votes

Solution for CodeRush

Finally, I figured it out: the shortcut is the numpad-plus key after installing CodeRush Express for Visual Studio.

Source: Stack Overflow → CodeRush Tricks of the Trade → Answer by moobaa

Solution for ReSharper

Or if you use Resharper, it's the extend/shrink selection feature accessible via Ctrl+W.

Source: Jetbrains.com → extend/shrink documentation

7
votes

If you want to select a line or lines you can use the combination of ctrl + E then U. This combination also works for uncommenting a complete line or lines(and also for indentation). This combination looks somewhat strange to work with, but it will get habituated very soon :)

You can also use Ctrl + X to cut an entire line. Similarly, you can use Ctrl + C to copy an entire line. As long as you don't have anything selected, these commands will work on the entire line.

7
votes

Out of the box ReSharper uses Ctrl+Alt+ to extend the selection. Check the main menu under ReSharper | Edit | Extend Selection

It's not quite what you're looking for as it does Word, then block where block keeps getting bigger (e.g. method, class, etc).

6
votes

My ReSharper keyboard shortcut was not set up to Ctrl + W.

The name for the command is ReSharper.Resharper_ExtendSelection.

2
votes

I noticed this "Triple Click" VS2010 add-on last time I searched through the add-on gallery. It's not quite what you're looking for (ie. it's not a hotkey and it won't select a block), but at least it will make it so that triple-clicking will select a whole line. If you're extra-adventurous, it comes with source.. so you could potentially extend the functionality and/or make it a hotkey yourself.

http://visualstudiogallery.msdn.microsoft.com/en-us/2bbdc70c-32f7-4b69-8cff-d8190cae0cc7

1
votes

Please refer to the Text Selection section of this document.

http://msdn.microsoft.com/en-us/library/da5kh0wa.aspx#editors

0
votes

Write a macro (or record one):

Sub SelectLine()
    DTE.ActiveDocument.Selection.EndOfLine()
    DTE.ActiveDocument.Selection.StartOfLine(vsStartOfLineOptions.vsStartOfLineOptionsFirstColumn)
    DTE.ActiveDocument.Selection.EndOfLine(True)
End Sub

Then bind it to whatever key you want in tools->options->environment->keyboard.

The only problem with this is it doesn't save the position of the cursor, which is mildly annoying.