sponsor Vim development Vim logo Vim Book Ad

aspvbs.vim : indenting for asp vbs files

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

created by
Tilmann Bitterberg
script type
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
<% If myPage = 1 Then %>
        <table> <!-- the indent of body is continued -->
<% 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)
    end if ' if asd then is closed

    ' normal asp indent here
    if foo then
        select case blah
            case foo
                Response.Redirect "google"
        end select
        Response.Redirect "yahoo"
    end if

    ' for the previous line, the html indenter wins
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:

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.