开发者

ASP.NET code formatting tool

Is there any tool for Visual Studio 2008 which can reformat ASPX c开发者_StackOverflow中文版ode to make it more presentable (eg insert line breaks, format the lines so they wrap when necessary, etc)?

Thanks


Have you tried hitting Ctrl+K+D? Is this what you're referring to?


http://blogs.msdn.com/markhsch/archive/2008/01/10/visual-studio-tip-autoformat-your-code.aspx

To have Visual Studio fix it all up nice and tidy for you, select the text, hold CTRL and hit K followed by F (CTRL+K-F). What I usually do is do a CTRL-A to select all text then do the CTRL+K-F combo. Voila!


You can also do it from the menu Edit > Advanced > Format Document or toolbar.

alt text http://img148.imageshack.us/img148/8872/formatdoc2.png


There are actually a number of tools dedicated to code formatting that you might want to take a look at. Visual Studio's formatting capabilities are actually quite limited, and a lot of projects I have worked on use one of these external tools.

Good luck!


This may not be directly related to your issue, but DevExpress has a free product CodeRush Express that will not only help with tidying but has a great interface for refactoring. Here is a link to their demo video. I've used their products for a few years and they really up your productivity.


After 11 years there is still no tool that does it right. All online formatters I found dont cope well with ASP (.NET/Core/Blazor) tags, and VS20xx (even the latest 2022) doesn't deal with tags from custom controls, it formats all, except for sections within custom tags. In my case, 90% of the aspx files.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜