Connecting Tech Pros Worldwide Forums | Help | Site Map

Auto html format/indent in Visual Studio .NET?

Steve Franks
Guest
 
Posts: n/a
#1: Nov 19 '05
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



Juan T. Llibre
Guest
 
Posts: n/a
#2: Nov 19 '05

re: Auto html format/indent in Visual Studio .NET?


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" <please@postreplyhere.com> wrote in message
news:BfCdnfNmzMw81KjeRVn-3Q@comcast.com...[color=blue]
> 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
>[/color]


Steve Franks
Guest
 
Posts: n/a
#3: Nov 19 '05

re: Auto html format/indent in Visual Studio .NET?



"Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message
news:On0HKqQwFHA.916@TK2MSFTNGP10.phx.gbl...[color=blue]
> 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.[/color]

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


Juan T. Llibre
Guest
 
Posts: n/a
#4: Nov 19 '05

re: Auto html format/indent in Visual Studio .NET?


re:[color=blue]
>Any ideas?[/color]

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" <please@postreplyhere.com> wrote in message
news:x9ydnQankMis-6jeRVn-qw@comcast.com...[color=blue]
>
> "Juan T. Llibre" <nomailreplies@nowhere.com> wrote in message
> news:On0HKqQwFHA.916@TK2MSFTNGP10.phx.gbl...[color=green]
>> 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.[/color]
>
> 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
>[/color]


Steve C. Orr [MVP, MCSD]
Guest
 
Posts: n/a
#5: Nov 19 '05

re: Auto html format/indent in Visual Studio .NET?


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" <please@postreplyhere.com> wrote in message
news:BfCdnfNmzMw81KjeRVn-3Q@comcast.com...[color=blue]
> 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
>[/color]


Juan T. Llibre
Guest
 
Posts: n/a
#6: Nov 19 '05

re: Auto html format/indent in Visual Studio .NET?


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]" <Steve@Orr.net> wrote in message
news:OHp4BWSwFHA.3588@tk2msftngp13.phx.gbl...[color=blue]
> 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[/color]


[color=blue]
> "Steve Franks" <please@postreplyhere.com> wrote in message
> news:BfCdnfNmzMw81KjeRVn-3Q@comcast.com...[color=green]
>> 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[/color][/color]


Closed Thread


Similar ASP.NET bytes