This question already has an answer here:
I have a bunch of assignment operations in Visual Studio, and I want to reverse them: i.e
i = j;
would become
j = i;
i.e. replacing everything before the equals with what's after the equals, and vice versa
Is there any easy way to do this, say something in the regular expression engine?
Cheers, Ed
I've improved the expression a little.
Replace
with
The reason is, it will look for lines starting with tab (\t). It will skip the lines starting with definition. E.g.:
Would ignore the int a, int b and int c and swap only the assignments.
Please see this question: Is there a method to swap the left and right hand sides of a set of expressions in Visual Studio?
My answer to that question has a macro that you can use to swap the assignments for a block of code.
Select the lines you want to swap, Ctrl+H, then replace:
with:
with "Look in:" set to "Selection"
That only handles C/C++ style identifiers, though (via the ":i"). Replace that with:
to replace anything on either side of the "=".
Also, since you mentioned in a comment you use ReSharper, you can just highlight the "=", Alt+Enter, and "Reverse assignment".