James Jenkinson
James Jenkinson

Reputation: 1651

Shortcut to copy multiple lines in Visual Studio

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?

Upvotes: 0

Views: 4930

Answers (2)

Mubin Icyer
Mubin Icyer

Reputation: 705

In new Visual Studio versions (my one is Version 17.7.4) you can duplicate a line or multiple lines just with Ctrl+D shortcut.

Upvotes: 0

Dave Kidder
Dave Kidder

Reputation: 1838

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)

Upvotes: 1

Related Questions