How to move the using directive inside the namespace on formatting?

Viewed 521

My concern is that in the code style that we use in the company the using directives are put inside the namespace, but I'm not able to do that automatically. I have and .editorConfig file that suggest to move the directives.

  • csharp_using_directive_placement = inside_namespace:suggestion

This works great, but what I want to achieve if it's possible is to move them automatically when I format the file.

Language: c# Visual Studio Version 16.9.1

1 Answers

You can actually change this in the settings directly:

Text Editor -> C# -> Code Style -> General -> 'using preferences:'

There you can change Preferred 'using' directive placement from Outside namepace to Inside namespace.

enter image description here

In addition you can also click on the light bulb next to a misplaced using directive and choose "Move misplaced using directives" and there, in the opening submenu "Fix all occurrences in: Document | Project | Solution" to select "Solution".

enter image description here

Related