22

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.

Jasper
  • 2,166
  • 4
  • 30
  • 50
Lernkurve
  • 20,203
  • 28
  • 86
  • 118

7 Answers7

15

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

Community
  • 1
  • 1
Lernkurve
  • 20,203
  • 28
  • 86
  • 118
  • Resharper selection only works for C#/VB, does not work for C++, same as built-in Ctrl+W – Yuan Mar 09 '11 at 02:32
7

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).

Mwiza
  • 7,780
  • 3
  • 46
  • 42
Wade Hatler
  • 1,785
  • 20
  • 18
7

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.

Mr_Green
  • 40,727
  • 45
  • 159
  • 271
6

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

The name for the command is ReSharper.Resharper_ExtendSelection.

Jasper
  • 2,166
  • 4
  • 30
  • 50
Daniel Harvey
  • 381
  • 5
  • 16
2

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

guesser
  • 672
  • 6
  • 11
1

Please refer to the Text Selection section of this document.

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

Rire1979
  • 652
  • 12
  • 24
0

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.

Jon Wingfield
  • 1,875
  • 2
  • 11
  • 8