471,354 Members | 2,047 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

Auto html format/indent in Visual Studio .NET?

Is there any way to tell VS to automatically reformat my HTML view to add
lines and tabs/spacing to create nicely formatted HTML in the viewer? I am
using Visual Studio 2005 .NET Beta 2

For example, let's say I paste this HTML into VS.NET "source" view:

<table><tr><td>val1</td><td>val2</td></tr></table>

I'd like to issue a command to VS to have it reformat this source and change
it to this in the editor:

<table>
<tr>
<td>val1</td>
<td>val2</td>
</tr>
</table>

Is there any such command or built-in functionality to do this?

If not, does anyone know of a 3rd party tool (or perhaps an alternative HTML
designer tool) that will do this?

Thanks!

Steve
Nov 19 '05 #1
5 3969
Try this :

"Tools", "Options", select the checkbox "Show All Settings",
scroll to "Text Editor", and then "All languages", "Tabs",
and set your default "Indenting" and "Tab" preferences.

It will work the way you set it from that point on.

It should reformat the HMTL source to the specs you select
when you close and open the file after pasting the code,
although I don't guarantee it.

I don't know if it will reformat poorly-formatted
code to the extent you say you want it reformatted.

It's worth a try, anyway.

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Steve Franks" <pl****@postreplyhere.com> wrote in message
news:Bf********************@comcast.com...
Is there any way to tell VS to automatically reformat my HTML view to add lines and
tabs/spacing to create nicely formatted HTML in the viewer? I am using Visual Studio
2005 .NET Beta 2

For example, let's say I paste this HTML into VS.NET "source" view:

<table><tr><td>val1</td><td>val2</td></tr></table>

I'd like to issue a command to VS to have it reformat this source and change it to this
in the editor:

<table>
<tr>
<td>val1</td>
<td>val2</td>
</tr>
</table>

Is there any such command or built-in functionality to do this?

If not, does anyone know of a 3rd party tool (or perhaps an alternative HTML designer
tool) that will do this?

Thanks!

Steve

Nov 19 '05 #2

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:On*************@TK2MSFTNGP10.phx.gbl...
Try this :

"Tools", "Options", select the checkbox "Show All Settings",
scroll to "Text Editor", and then "All languages", "Tabs",
and set your default "Indenting" and "Tab" preferences.

It will work the way you set it from that point on.

It should reformat the HMTL source to the specs you select
when you close and open the file after pasting the code,
although I don't guarantee it.


Thanks.I fFound that but its not making any difference. Here's what I am
doing:

I do not have a Show All Settings checkbox. However I did fine Text
Editor-All Languages-Tabs. In the top section none of the radio boxes for
"none,block,smart" were checked. I tried selecting "block", then I created
a new page and cut/pasted html but it did not reformat it. I tried saving it
and it didn't make a difference. Then I switched to Design view and back to
Source mode, still no difference. Then I repeated the same thing but with
"smart" radio selected. Nonthing made a difference.

Any ideas?

Thanks,

Steve
Nov 19 '05 #3
re:
Any ideas?
Nailed it...

"Tools", "Options", scroll to "Text Editor", and then "HTML",
"Miscellaneous", select "Format HTML on Paste".

That does exactly what you want.

It's amazing what you can find out by playing around with the IDE.


Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Steve Franks" <pl****@postreplyhere.com> wrote in message
news:x9********************@comcast.com...
"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:On*************@TK2MSFTNGP10.phx.gbl...
Try this :

"Tools", "Options", select the checkbox "Show All Settings",
scroll to "Text Editor", and then "All languages", "Tabs",
and set your default "Indenting" and "Tab" preferences.

It will work the way you set it from that point on.

It should reformat the HMTL source to the specs you select
when you close and open the file after pasting the code,
although I don't guarantee it.


Thanks.I fFound that but its not making any difference. Here's what I am doing:

I do not have a Show All Settings checkbox. However I did fine Text Editor-All
Languages-Tabs. In the top section none of the radio boxes for "none,block,smart" were
checked. I tried selecting "block", then I created a new page and cut/pasted html but
it did not reformat it. I tried saving it and it didn't make a difference. Then I
switched to Design view and back to Source mode, still no difference. Then I repeated
the same thing but with "smart" radio selected. Nonthing made a difference.

Any ideas?

Thanks,

Steve

Nov 19 '05 #4
Simply press:
Control + K
Control + D

....and the code will be auto-formatted. This works in HTML and in code
(VB/C#) windows.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Steve Franks" <pl****@postreplyhere.com> wrote in message
news:Bf********************@comcast.com...
Is there any way to tell VS to automatically reformat my HTML view to add
lines and tabs/spacing to create nicely formatted HTML in the viewer? I
am using Visual Studio 2005 .NET Beta 2

For example, let's say I paste this HTML into VS.NET "source" view:

<table><tr><td>val1</td><td>val2</td></tr></table>

I'd like to issue a command to VS to have it reformat this source and
change it to this in the editor:

<table>
<tr>
<td>val1</td>
<td>val2</td>
</tr>
</table>

Is there any such command or built-in functionality to do this?

If not, does anyone know of a 3rd party tool (or perhaps an alternative
HTML designer tool) that will do this?

Thanks!

Steve

Nov 19 '05 #5
Yup.

That does exactly the same thing, but setting the
"Format HTML on Paste" option doesn't even
require doing that, when pasting.

That's a nifty keyboard shortcut when you're a sloppy coder, though.
Two commands, and everything is formatted for you.

;-)

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Steve C. Orr [MVP, MCSD]" <St***@Orr.net> wrote in message
news:OH**************@tk2msftngp13.phx.gbl...
Simply press:
Control + K
Control + D

...and the code will be auto-formatted. This works in HTML and in code (VB/C#) windows.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net

"Steve Franks" <pl****@postreplyhere.com> wrote in message
news:Bf********************@comcast.com...
Is there any way to tell VS to automatically reformat my HTML view to add lines and
tabs/spacing to create nicely formatted HTML in the viewer? I am using Visual Studio
2005 .NET Beta 2

For example, let's say I paste this HTML into VS.NET "source" view:

<table><tr><td>val1</td><td>val2</td></tr></table>

I'd like to issue a command to VS to have it reformat this source and change it to this
in the editor:

<table>
<tr>
<td>val1</td>
<td>val2</td>
</tr>
</table>

Is there any such command or built-in functionality to do this?

If not, does anyone know of a 3rd party tool (or perhaps an alternative HTML designer
tool) that will do this?

Thanks!

Steve

Nov 19 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by Seth | last post: by
1 post views Thread by Craig Hunt | last post: by
1 post views Thread by stonny | last post: by
reply views Thread by Jack | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.