Visual Studio 2015 behavior in nested using statements
From a similar question asked before , it is known that the preferred way of deferred nested statements using
(this is the default preview of Visual Studio 2015):
using (var enumerator1 = list1.GetEnumerator())
using (var enumerator2 = list2.GetEnumerator())
{
// Use enuemrator1 and enumerator2 here
}
However, I found that the behavior was changed in Visual Studio 2015 when I type the following:
using (var enumerator1 = list1.GetEnumerator())
and click ↵, the cursor is indented on the second line:
using (var enumerator1 = list1.GetEnumerator())
‸ // Text caret appears here instead of at the same level of
// indent of the previous line
How can I return the previous behavior and what is the reason for changing this behavior?
If you have ReSharper you need to override the named setting Indent nested "using" statements
.
It can be found under Code Editing
=> C#
=> Formatting Style
=> Other
.
Even if the option is disabled, the caret will still be indented. However, once you create a new line, ReSharper will format your block correctly using
: