From the course: Visual Studio Code Productivity Tips

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

A simple technique to copy code blocks

A simple technique to copy code blocks - Visual Studio Code Tutorial

From the course: Visual Studio Code Productivity Tips

Start my 1-month free trial

A simple technique to copy code blocks

- [Instructor] I'll bet that you have your favorite way of moving text around inside the code editor. This tip looks at a relatively unknown technique that allows you to move text using just your keyboard, and no, this tip is not showing you how to cut and paste code in the code editor. I assume you know how to do that. Instead, we'll look at a built-in VS command. It's almost embarrassing to show this tip, because it's so easy, but I have found that many people don't know about this technique. The idea is I want to move this variable declaration on line six up couple of lines. I put my cursor somewhere in that line of code, like that. Then I hold down the Alt key, and I press the up arrow to move that line of code. Notice that the cursor didn't need to be at the beginning of the line. I can put anywhere in the line and move it. To work with multiple lines, select the lines that you want, like this, and then use the same keystrokes, Alt down or Alt up. That's it. It doesn't get much…

Contents