Skip to content

Tip 2.13: You can cut and paste a collapsed block of code

September 21, 2014

“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’

Sara Ford’s Blog

Sara Aside

You can cut and paste a collapsed block of code, keeping all of the code inside intact. Of course, this is exactly what you would expect, but she never thought about trying it.

With a block of code collapsed, as indicated to the right of the code lines shown in the preceding illustration, select the block and cut or just cut the line via your favorite mechanism for cutting a line. Now navigate to the desired location and paste.

Note the code will be automatically expanded upon pasting.

The idea behind this tip is that you want to quickly cut and paste an entire function, but the function is quite long. You can use the approach shown in the previous tip (specifically, Ctrl+M, Ctrl+M to toggle between expanding and collapsing a block of code) to collapse the function to just the function name. Then press Ctrl+L to cut the current line. Now you can paste the function wherever you want.

Happy Programming! =)

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: