ReSharper Tip of The Week #3: Moving Things Around

An entry about tools Publication date 3. June 2008 21:54

I’m going to keep this weeks ReSharper tips really simple, as the weather is way too nice to be stuck indoors - at least here in Norway; the sun is shining from a cloudless sky, seagulls are cawing in the distance, and temperatures are above 20 degrees even this late in the evening (and I hear talk that the water temperature is not too bad out in the fjord either, although I might just wait a bit longer before diving in… :p).

But I digress... Today, we’ll look at possibly one of the most finger-twisting ReSharper keyboard shortcuts: Ctrl+Shift+Alt, [Direction Keys]. Yeah, not exactly easy on the fingers that one – but it’s a really handy feature.

By using the Code Clean-up feature (Ctrl+E, Ctrl+C), you can have ReSharper order all the members in your classes alphabetically. However, sometimes that’s not quite what you want. Instead, placing your cursor on for example the line of a method signature, you can press Ctrl+Shift+Alt and then use the Up and Down arrow keys to sort it manually. When you invoke the key combination, the block you’re moving is coloured in blue:

Move block

You can move just about anything this way, not just members in a class – statements within a method works too, for example:

Move statement

You can move things left and right too, not just up and down. For instance, you can swap the left and right-hand side of an expression:

Move statement

…or reorder the parameters of a signature:

Move parameter

Note however that reordering parameters this way will not safely refactor any usages of this method - for that, you should instead use Ctrl+R, Ctrl+S which brings up the Change Signature dialogue.

And that’s about it really – a simple, handy feature that will help you keep your code files neatly organized.

Previous ReSharper Tips of The Week

#1 – Finding Things
#2 - Navigation

Be the first to rate this post

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Comments

Powered by BlogEngine.NET 1.4.5.0

Welcome!

My name is Fredrik Kalseth, and this is my blog - thanks for visiting! I am fortunate enough to work with what I love for a living, and this blog is essentially the biproduct of that.

I work as a senior consultant for Capgemini, and am also an active participant in the Norwegian .NET community, as an avid attendee but also as a speaker (most recently at NNUG and MSDN Live).

As a developer, I have a wide circle of interest. My primary passion is for agile, test-driven development, with focus on best practices and clean code. That said, I also love to work on the frontend, especially with web development.

On Twitter? My handle is fkalseth. On LinkedIn? I`m there too.

Disclaimer

This is a personal blog; any opinions expressed here are my own and do not necessarily reflect those of my employer. All content herein is my own original creation, and as such is protected by copyright law. Unless otherwise stated, all source code posted on this blog is freely usable under the Microsoft Permissive License.

What Readers Talk About

Comment RSS