sponsor Vim development Vim logo Vim Book Ad

aspvbs.vim : indenting for asp vbs files

 script karma  Rating 26/8, Downloaded by 1350  Comments, bugs, improvements  Vim wiki

created by
Tilmann Bitterberg
 
script type
indent
 
description
Having to write active server pages with visual basic script included is pain enough. Vim eases this and with this automatic indenter even more.

This script tries to be very smart and will probably fail horribly. Since version 0.4 (there is no 0.3) aspvbs.vim will do indenting based on the context. That means when you are in an html context, the html indenter will be used, otherwise the ASPVBS indenter.

But wait, there is even more! The script tries to pick up the previous indent of each block, so when you open a new ASP block with <% the indent of the last ASP block will be resumed.

The script works best when an opening <% and a closing %> are placed on a line on their own. You can most definitely break the script by writing code like '%><html></html><% ...'

Here is an example of its indenting sprinkled with comments:

<%
function baz
    if asd then
        bcd
%>
<html>
    <head>
        <title><%=myTitle%></title>
    </head>
    <body>
<% If myPage = 1 Then %>
        <table> <!-- the indent of body is continued -->
            <tr>
                ...
            </tr>
        </table>
<% End If %> <!-- the indent of < % if mypage = 1 is picked up -->
    </body> <!-- the indent of </table> is continued
<%
        ' the indent of line 4 is continued (inside if)
        efg
    end if ' if asd then is closed

    ' normal asp indent here
    if foo then
        select case blah
            case foo
                Response.Redirect "google"
        end select
    else
        Response.Redirect "yahoo"
    end if
    =this_is_a_statement()
%>
</html>
Test1<%testin1%>Test2<%testin2%>test3<%statement

    ' for the previous line, the html indenter wins
    =this_is_a_statement2()
end function ' close function baz
%>

 
install details
Copy the script into your $VIMRUNTIME/indent/ folder and make sure you use the filetype feature. You should at least have "filetype indent on" in your vimrc
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
aspvbs.vim 0.4 2005-05-04 6.0 Tilmann Bitterberg Major feature enhancements. Context based indenting, resuming indent and tons of other stuff.
aspvbs.vim 0.2 2005-04-23 6.0 Tilmann Bitterberg Incorporated case insensity fixes by Tavish Robinson,
added indent on ending keywords,
added class keyword,
speed improvements
aspvbs.vim 0.1 2005-04-09 6.0 Tilmann Bitterberg Initial upload
ip used for rating: 18.221.146.223

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github