0

Maybe this is wishful thinking, but is there a way to quickly copy, or even just select, multiple lines quickly in Visual Studio? Similar to a multiple yank in vim.

I'm aware of the copying a single line, by just pressing Ctrl+C with nothing selected, but can't find any way of doing this for n lines.

If there's nothing that comes with it, is there any way to write a macro to achieve this?

James Jenkinson
  • 1,563
  • 2
  • 16
  • 33
  • Any reason why you don't want to use the mouse to copy? – rrirower Oct 24 '14 at 12:14
  • 2
    Because I am unbearably lazy. – James Jenkinson Oct 24 '14 at 12:45
  • Because having to stop typing, and reach for the mouse, whilst may sound trivial, it breaks workflow, and makes one lose their train of thought. This is inconvenient. – James Jenkinson Oct 24 '14 at 12:47
  • Possible duplicate of [Favorite Visual Studio keyboard shortcuts](http://stackoverflow.com/questions/98606/favorite-visual-studio-keyboard-shortcuts?rq=1). – rrirower Oct 24 '14 at 13:04
  • There's definitely some good stuff in there, but having gone through the responses, I can't find anything that matches my question, so I wouldn't say it's a duplicate. – James Jenkinson Oct 24 '14 at 13:39
  • Not even the block copy (Shift & Alt & arrow keys)? – rrirower Oct 24 '14 at 13:41
  • No, because that still requires my cursor to move to the start in the line to copy/remove the lines I want. If I happen to be in the middle of the line, as often seems to be the case, when I decide to do either command, then it takes too long, and we're back at square 1. – James Jenkinson Oct 24 '14 at 13:45
  • _Particularly_ with alt in fact, it's slightly better to just use shift and arrow, but still not ideal. – James Jenkinson Oct 24 '14 at 13:46

1 Answers1

1

To select multiple lines using the keyboard (starting from the current line, selecting downwards):

  1. Press HOME (to move the cursor to the first character of the current line)
  2. If the cursor is NOT all the way to the left (i.e. Col 1) press HOME again
  3. While holding the SHIFT key press the DOWN ARROW (each subsequent DOWN ARROW will select an additional line)

Alternatively the UP ARROW can be used to select lines from the starting line up.

Additional info: Combinations of SHIFT, CTRL and all the ARROWS can be used for various cursor moving and character selection, examples:

  • CTRL + Left (move the cursor to the start of the current word)
  • CTRL + Right (move the cursor to the start of the next word)
  • SHIFT + LEFT (select the previous character)
  • CTRL + SHIFT + RIGHT (select all characters to the right of the cursor, in the current word)
Dave Kidder
  • 1,758
  • 13
  • 16
  • 1
    Thanks, I guess all I was missing was the awareness of the home key. It'd still be nice if there was something closer to vim's [n]yy command, but there were are. – James Jenkinson Oct 24 '14 at 14:57