Format the Current Document or Selection (HTML Designer)

Keyboard:  CTRL + K, CTRL + D (document); CTRL + K, CTRL + F (selection)
Menu:  Edit -> Advanced -> Format Document; Edit -> Advanced -> Format Selection
Command:  Edit.FormatDocument; Edit.FormatSelection
Versions:  2008,2010
Published:  12/18/2010
Code:  vstipEdit0089

 

In vstipEdit0057 (https://blogs.msdn.com/b/zainnab/archive/2010/05/19/format-the-current-document-or-selection-vstipedit0057.aspx) I showed you how to format code.  I thought it would be a good idea to look at the same thing from a web project perspective.  Let's say you have some HTML you just wrote:

image

 

But you want to clean it up a bit.  Just select everything you want formatted, then RIGHT CLICK, and choose "Format Selection" (CTRL + K, CTRL + F):

image

 

Here is the result:

image

 

This uses the formatting rules found at Tools -> Options -> Text Editor -> HTML -> Formatting to determine what to do.