Reorder code without the copy-paste fuss
Have you ever wanted to reorder code members — say, members in a class or just member statements — without the usual copy-paste routine? With ReSharper, this is easy.
The shortcut to remember here is Ctrl+Shift+Alt + Arrow buttons. While holding the Ctrl+Shift+Alt combination, the arrow keys have a multitude of uses depending on where the caret is in your code and what code block you have selected. Here are some examples:
Pressing the left and right arrow keys while on a member of an addition operation such as
a + bwill move the operand left or right, if possible. For instance, with the cursor on
b, pressing Ctrl+Shift+Alt+Left will change the expression to
b + a.
Pressing the up and down arrow keys moves the whole statement up and down. Note: if you want to have a statement moved inside a code block that follows it, use right/left keys instead of up/down.
Having the caret at the method declaration, the up/down keys (together with Ctrl+Shift+Alt, of course) move it up and down with respect to other member declarations. This lets you reorder fields, properties, methods and events how you wish.
Since many of these refactorings rely on the exact code elements being selected, ReSharper offers useful shortcut keys in order to extend and shrink selection. An extension can grow from a single identifier, to a whole statement, to all statements, to the containing method, and so on. Use Ctrl+W to extend selection and Ctrl+Shift+W to shrink it.