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:
You can move just about anything this way, not just members in a class – statements within a method works too, for example:
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:
…or reorder the parameters of a signature:
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