Editing Tips & Tricks

Know everything there is to know about editing code.

Editing code is a core activity in the IDE. ReSharper and Rider can help write clean code faster, and more efficiently.

In this playlist we're going to have a look at the many editing and code completion features in ReSharper and Rider, and how to effectively use them.

Move Code

Move code the smart way!

Move code the smart way! 👈🙃👉

Instead of cutting and pasting lines, and breaking code, let's move things semantically: First we put our caret on the code intended to be moved. Then, we use Code | Move Statement Up/Down to rearrange it. Despite the refactoring name, this also works for methods, properties and other members. Placing the caret at the closing brace of a block statement, like if or while, even lets us expand and shrink the scope.

We can also reorder parameters of signatures. Again, we just place our caret on a particular parameter, and use Code | Move Element Left/Right to specify its new position. Note that if our method already has usages, we might consider using the Change Signature refactoring instead, which would update the argument order.

Alright, now move move move! 👇😌👆

See Also