Hello everyone,

I have been thinking about implementing this little feature to help
clean up my code.  Here's the scoop.  I'm a Perl programmer and I use
a templating module called HTML::Mason which allows perl code within
certain "tags".  Here's an example of the code:

<% $tmpl->template_top()  %>

% $m->call_next();

<% $tmpl->template_bottom  %>


<%init>
use Myapp::HTML;
use Myapp:Config qw(IMG_BASE_URL);

my $tmpl = Myapp::HTML->new({
                               title => 'Something',
                               js => ['jquery.js'] },
                               );
</%init>

<%flags>
inherit => undef
</%flags>


Between the <%init> tags is just straight Perl code.  I have two maps
I've setup in vim that will run the contents of a file through an
external program (perltidy) and clean up my code.  They are:

map ti :%!perltidy " clean entire file
map mt :.!perltidy " clean current line

Just wondering if there'd be a way that I could write a map that would
work for a current "block" of code.  Maybe autodetect what block I'm
in?  In this case whatever block I'm in (init).  If I couldn't
autodetect the block I'm in, that'd be ok cause I could just map the
few types of blocks into separate map commands.

Should I go about this with a regex and then pass that line range to
the external command?

Any help is greatly appreciated!

Kevin
--
Kevin Old
[EMAIL PROTECTED]

Reply via email to