Search code examples
c#visual-studio-2017using-directives

Visual Studio 2017 Collapsing also removes unused using


I am dealing with the unfortunate situation of using a temporary PC for my work right now, and the pre-installed Visual Studio 2017 is determined to make my life hard.

When I collapse content in the C# editor (Keyboard Shortcut: Ctrl + M + O), not only does it collapse content, but it also goes ahead and removes all the unused using statements, which is NOT what I want it to do. I can't figure out why.

Is there some hidden setting that might let me turn this feature (if it is a feature at all) ON/OFF?


Solution

  • Alright, I painstakingly went through the entire Option window and found it!

    Go to:

    Tools > Options > Text Editor > C# > Code Style > Formatting

    And the following option is the culprit:

    enter image description here

    God that's buried under a mountain of stuff.

    EDIT:

    In case the image link ever gets broken, uncheck the Remove unnecessary usings under Perform additional code cleanup during formatting section.