views:

57

answers:

2

I have an annoying problem with Visual Studio 2008.

When I run the "format code" command ("control+k, control+d") -- it will insert a carriage return. How do I get it to stop doing this???

For example:

<label for="shipCompanyName">Company Name:</label>

undesirably becomes

<label for="shipCompanyName">
Company Name:<label />

A: 

I use ReSharper.

You can configure whether to wrap or not in ReSharper.

ReSharper -> Options -> C# -> Formatting Style -> Line Breaks and Wrapping -> Wrap long lines

brickner
I don't have resharper on this machine
rsturim
OK, it's just a suggestion that will solve your problem.
brickner
I agree. It may not be the right answer for OP, but I wouldn't say it deserves a downvote as it IS an answer that works.
Bradley Mountford
+1  A: 

Go to Tools, Options. Open Text Editor, HTML, and Format. Uncheck "Wrap tags when exceeding specified length".

Oddly, VS2008 doesn't have the same option for XML.

Brad
That was the first thing I thought of too. So I tried it and found that it works for the design view, but does not work for ctrl-k ctrl-d or ctrl-k ctrl-f.
Bradley Mountford
@Bradley: Odd, I only tested it on the source of an ASPX page in a ASP.NET project (not a random HTML page in a csproj or anything), but Ctrl-K, Ctrl-D worked fine. Are you sure there aren't any syntax or formatting errors in the page (improper nesting, unclosed tags)? That will stop Ctrl-K, Ctrl-D from working. We have one page in particular that refuses to auto-format due to some Javascript in the page.
Brad
@Brad: That is entirely possible. We have loads of HTML that throws validation warnings in VS (due to server side conditional statements), but renders valid once the server side code runs.
Bradley Mountford