views:

59

answers:

3

For example I have this code:

if (cond) {
    lock (locker) {
        foreach (var item in list) {
            callFunc(item);
        }
    }
}

And I now want to remove all those brackets because they are too redundant. I always do it manually but I find myself doing this often so was wondering if there's a shortcut I missed or easy way to do this. Google didn't find anything.

A: 

I am not aware of such a shortcut, but I also dun believe there exists one. The only better way I can think of is by using the search & replace feature. But I doubt you are already using that anyway.

loxxy
+4  A: 

There seems to be no such option in Visual Studio. You could download JetBrains Resharper, a great plugin for Visual Studio that allows you to (among many other things) specify the code format you like with indentation, braces layout etc. Then you just run the reformat code command.

A word of warning: once you start using ReSharper you will become addicted and be completely unable to work without it. :)

Crassy
A: 

I think, the best way would be to write a python script to do this. (or with any other language that's easy to manipulate text with).

Klaim