Is there a shortcut to swap/reorder parameters in visual studio IDE?

Viewed 6615

I have a common issue when working with code in the IDE:

string.Concat("foo", "bar");

and I need to change it to:

string.Concat("bar", "foo");

Often I have several of these that need to be swapped at once. I would like to avoid all the typing. Is there a way to automate this? Either a shortcut or some sort of macro would be great if I knew where to start.

Edit: changed to string.Concat to show that you can't always modify the method signature. I am only looking to change the order of the params in the method call, and nothing else.

2 Answers

I had a lot of code with this function:

SetInt(comboBox1.Value + 1, "paramName", ...
SetInt(comboBoxOther.Value, "paramName", ...

And I needed to swap only the first two parameters;

I ended up using some text editor with regular expression management (like Scite), and using this one saved me hours:

Find: SetInt(\([.a-z0-9]+[ + 1]*\), \("[a-z0-9]+"\)
Replace: SetInt(\2, \1 
Related