简体   繁体   中英

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

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

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 .

在此处输入图像描述

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" .

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM