Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I stop Visual Studio 2008 from wrapping lines when formatting code

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 />

like image 732
rsturim Avatar asked May 20 '10 19:05

rsturim


People also ask

How do I wrap code to next line in Visual Studio?

Windows: Ctrl + Shift + press the key "P". Now on the command line, type Toggle Word Wrap and press Enter . Mac: Command + Shift + press the key "P". Now in the command line, type Toggle Word Wrap and press Enter .


2 Answers

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.

like image 128
Brad Nabholz Avatar answered Sep 16 '22 23:09

Brad Nabholz


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

like image 26
brickner Avatar answered Sep 19 '22 23:09

brickner