views:

1959

answers:

5

In Visual Studio 2005, is there a way to indent correctly the tags in the aspx file (not in .cs files but really in ASPX files which contain HTML/ASP code)?

+4  A: 

You can fix indenting using the shortcut Ctrl-K+D

Dan
And it works in 2008 as well. You are my hero for at least the next 5 minutes.
TheTXI
yea baby! I wrote this on my whiteboard!
Saif Khan
A: 

Ctrl-A (select all), Ctrl-K-F has worked for me.

Sachin
+2  A: 

Those keystrokes translate to:

  • Ctrl-K, Ctrl-D : Edit/Advanced/Format Document
  • Ctrl-A, Ctrl-K, Ctrl-F : Edit/Select All, Edit/Advanced/Format Selection

For some reason, the latter seems to work better for me.

Note, these also work for other file types: C#, VB, XML etc...

James Curran
A: 

XML Editor toolbar -> Format whole document.

Izmoto
A: 

You want to go to Tools > Options and then navigate to Text Editor > All Languages > Tabs.

The settings you want are: Under Indenting click the "Smart" Radio box for smart indenting. Under Tab you want tab size 4 and indent size 4. And check the radio button labeled Insert Spaces.

You can also change these settings for each language individually. Also some of them don't have Smart indenting, like html.