Visual Studio Tips: Selection shortcuts for lazy coders

VisualStudioLogoHere are a couple of tricks you may not know for selecting and editing text with as few keystrokes as possible.

Don’t forget students can get Visual Studio Professional for free through DreamSpark!

Find more Visual Studio tips and tricks here

Cut, Copy, Paste: Three commands programmers use every day. Let’s face it, all coders are basically lazy: The less keystrokes the better. That’s why it’s nice to know the fastest way to select the text you want to cut, copy & paste. In this post I’ll share a few different techniques for selecting code. You probably know a couple of the tricks listed below, but did you know all of them? If you have any tricks of your own, please share!

  • How do I select one word at a time?
  • How do I select to end of line?
  • How do I select an entire line of code as quickly as possible?
  • How do I select multiple lines of code starting from a particular column?
  • Two Bonus tips (You have to scroll down to find them)

How do I select one word at a time?

You can select text using the keyboard as well as the mouse. If you put the cursor anywhere in the code and hold down the <SHIFT> key and then use the right or left arrow key, you can make a selection one letter at a time.


If you hold down the <SHIFT> and <CTRL> keys then using the arrow keys will select one word at a time.

selecting one word at a time

How do I select to end of line?

If you hold down the <SHIFT> key and then press the <END> key you select from the cursor location to the end of the line

select to end of line

How do I select an entire line of code as quickly as possible?

I discovered this trick by accident, and fell in love with it. If you want to select an entire line of code, all you need to do is put the cursor anywhere on the line, do not make any selection at all and then do the desired command (Cut, copy, or paste). When there is no text selected, cut, copy and paste default to selecting the entire line. Try it!

How do I select multiple lines of code starting from a particular column?

Have you ever tried to select code on multiple lines? If you just start in the middle of a line of code and select multiple lines of code you end up with a selection like this:

select multiple lines of code

Now try holding down the <ALT> key as you make a multiple line selection. This works if you are selecting with the keyboard or the mouse.

box select

When you use the <ALT> key you get something called a box select. This can be useful if you are trying to copy a list of variable names, comments, or namespaces without the entire line of code.


Okay if you actually scrolled down this far, here are the two bonus tips I promised.

Not only can you select code over multiple lines with the <ALT> key, you can actually edit code on multiple lines as well. Let’s say you have a list of variables declared as private and you decide they need to be public. Use the <ALT> key to do a multiple line selection of the keyword private across all the declarations.

box edit

Now start typing the word public, as you type it will replace the selected text on each line with the new text you type

box editing


Last but not least, you can actually insert text on multiple lines of code using the box select technique as well. Let’s say I wanted to add some similar comment text after each variable declaration above. Use the <ALT> key to do a multiple line selection, but make your selection at the position in the line where you want to add the comments.

box insert

Now start typing the text you want to insert, as you type it will be added to all the lines.

box insert

If you like that multi-edit feature, you may also want to check out this neat little add-on for Visual Studio called MultiEdit Extension for Visual Studio. After you install the extension, if you hold down <ALT> while mouseclicking in the editor it will add multiple selection points wherever you clicked. Then you just type and your text is added to all the selected positions. Scott Hanselman wrote a blog post about it here. Thanks Andrew for pointing out this neat little extension.

Happy coding!

Comments (19)

  1. Firas says:

    Thanks a lot, really useful shortcuts 🙂

  2. Alex Peta says:

    You saved me a lot of keystrokes!

  3. Sanjay says:

    Thanks.. helpful post..

  4. Kamran says:

    Nice one Susan

  5. Vamshi says:

    Very helpful shortcuts. Thank you very much.

  6. Thanks. These I really need to remember and I'm sure I will since they are really helpful.

  7. pedro says:

    Seiously? This is really ild News 🙂

  8. Susan Ibach says:

    @Pedro – agreed these are not new features, but so many little tips and tricks out there many coders haven't had a chance to discover yet. I always recommend the Visual Studio site if you want the first to know tips on VS 2013.

  9. Great stuff.  VIM for Visual Studio!

  10. Susan Ibach says:

    @Andrew – I hadn't seen that add-on before! Very cool, I'll add it to the text of the blog post, for those people who don't always get to the comments

  11. Rohit says:

    multiple lines edit is awesome…..

    Thanks you very much

  12. Prageeth says:

    Cool.Thanks a lot for sharing

  13. Sarah s says:

    Thanks a lot ..really usefull tricks

  14. Brien says:

    Very nice post. Thank you for your information

  15. Kirk says:

    After a few unsuccessful google searches trying to find a quick way to turn a radiolist into a list box without all coding each line individually I found this.  Very helpful, thanks! I can definitely see it increasing my efficiency.

Skip to main content