Ziff Davis EnterpriseDevLife
Advertisement

Sunday, April 20, 2008 9:51 AM/EST

One of my favorite, unsung features in Visual Studio

I have been spending a lot of time in XML lately because I like to muck directly with the Entity Data Model.

This has led me to discover a Visual Studio feature that has been there since at least Visual Studio .NET 2003 (I don't have 2002 installed anywhere to see). It kills me that there are so many things in VS that I have never even played with and I keep promising that one day (when I have some of that mythical "free" time) I am going to go through every menu option to see what's in there.

The tool that I am currently quite fond of though is the one that allows you to reformat a document or a section of a document.

You'll find it under
Edit
--Advanced
----Format Selection

This is available for code and for XML. But if I have an XML doc open there are even a toolbar buttons for it and it's counterpart, Format Document.

And they will take code or xml that is a mess and format and fix it up so that it's beautiful.

Sometimes when I make drastic changes in the EDMX designer, some of the xml in the file ends up being one long string with tens of thousands of columns and completely unreadable, so the reformatting is a blessing.

It's also been really helpful for formatting code that I need to copy and paste when writing blog posts, articles or my book - or just my own readability.

These are only the tip of the iceberg though. Take a look at the other options in the Edit/Advanced sub menu to get an idea of how Visual Studio can help you along these lines.

Along the lines of "I didn't know that was in there!" I would definitely recommend subscribing to MSDN blogger Sara Ford's blog as she has an awesome and continuing series of posts titled "Did you know?" that now has over 200 tips!

TrackBack

TrackBack

http://blogs.devsource.com/cgi-bin/mte/mt-tb.cgi/13425

Comments (4)

Microsoft enhanced the "Format Selection" in Visual Studio 2005 and higher to work with .aspx pages too. I often use it to reformat the html tags by selecting the entire document and executing "Format Selection" command from the "code view" menu.

I've always hit Ctrl-K, Ctrl-D to get it auto-format my document.

Shail :

Hi,
One thing I noticed, when you hit Ctrl + K,D, it formates your document. But it replaces all your Tags to "Spaces". This increases the size of document.

Lets say that I have opened a HTML document in VS 2005 and I did a format. Initially the size was 17 KB, but after format it is now 28 KB. So I went into settings and instructed VS to "Keep Tags".

Anyone observed this too ?
Thank You,

Chuck snyder :

To keep the tabs, goto Tools/Options

then select Text Editor/All languages/Tabs.

Check "Keep Tabs" and when reformatting the program will convert spaces to tabs (on the front of the line anyway).

Post a Comment

 
 

Advertisement

Syndication

Subscribe: