Dumping webforms views

Want to switch from using the Webforms ViewEngine to the Razor ViewEngine?
Got a lot of Webforms views? I know they can be used side by side, but if you feel like converting and are comfortable with vi then these substitutions can help you along your way

Replace <% if and <% foreach (or anything but <% { really) with @if and @foreach
:%s/<% \([^}]\)/@\1

Replace any <%= followed by a space with @
:%s/<%= /@

Same as above but omit the space

Get rid of any remaining <%

Get rid of any %>

This won’t be perfect, but will get you close with very little effort.

Add this to your .vimrc file and do it with one command


function! DumpWebforms()
  %s/<% \([^}]\)/@\1
  %s/<%= /@
Then invoke using :call DumpWebForms()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s