views:

54

answers:

2

In VS2008 (Tools -> Options, Text Editor, HTML, Format, Tag Specific Options) you can control the automatic formatting of most tags.

However, I'd like to have VS automatically format my @p Page directive so that instead of:

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Foo.aspx.vb" Inherits="WebRoot.Foo"
   MasterPageFile="~/WebRoot.Master" %>

I get:

<%@ Page Language="vb" AutoEventWireup="false" 
         CodeBehind="Foo.aspx.vb" 
         Inherits="WebRoot.Foo"
         MasterPageFile="~/WebRoot.Master" 
%>

Is this possible?

A: 

You can control the Page and Register directives the same way as other tags.

Tools > Options Text Editor > HTML > Format > Tag Specific Options > ASP.NET Controls

Page
Scroll and find Page (<%@ Page)

Register
Add a new tag for Register (<%@ Register)

Micah Burnett
In VS2008, there doesn't seem to be any way to control the formatting of the attributes within the tags.
chris
A: 

I thought ReSharper might let you do something like this, but it looks like you can't do custom formatting rules; only the presets it comes with. (See this question)

But you should be able use a regex tool to do this, or maybe write a macro to run when you build your project.

Adam Neal