How do you auto format code in Visual Studio?

2019-01-07 01:32发布

I know Visual Studio can auto format to make my methods and loops indented properly, but I cannot find the setting.

21条回答
Luminary・发光体
2楼-- · 2019-01-07 02:03

The original question said "I cannot find the setting."

Simple answer is: Look at top menu, then

Edit --> Advanced --> Format Document

You will also see the currently assigned key strokes for that function. Nothing special to memorize. This really helps if you use multiple developer environments on different operating systems.

查看更多
Melony?
3楼-- · 2019-01-07 02:03

With the Continuous Formatting extension (commercial, developed by me), the code is formatted really automatically as you type.

查看更多
The star\"
4楼-- · 2019-01-07 02:04

If you can afford it (or if you're eligible for the 30-day free trial) Jetbrains ReSharper can reformat a whole project directory.

Just install -> Right-click a directory -> select Cleanup Code from the context menu.

查看更多
登录 后发表回答