Vim regex

| | Comments (0) | TrackBacks (0)
Add to delicious Digg This Add to My Yahoo! Add to Google Add to StumbleUpon

I was wanting to start some comments in a large Perl module the other day and not really had to use Vim's regexp to any great degree because I know Perl I decided to see if it could be done.

I decided to add a little bit of pod above every funcion. The following was the result Remember In vim the ^M is a control character for carriage return and can be achieved by holding down the control key and pressing carriage return.

The following regex

:%s/^sub\(.*\) {\(.*$\)/=head \1\(\)^M^MDescrition:^M^M=cut^Msub \1{\2/

changes

sub summit_sub {
stuff;
}

to

=head summit_sub()

Descrition:

=cut
sub summit_sub{
stuff;
}


The following regex

:%s/^sub\(.*\)\n{\(.*$\)/=head \1\(\)^M^MDescrition:^M^M=cut^Msub \1{\2/

changes

sub summit_sub
{
stuff;
}

to

=head summit_sub ()

Descrition:

=cut
sub summit_sub {
stuff;
}

0 TrackBacks

Listed below are links to blogs that reference this entry: Vim regex.

TrackBack URL for this entry: http://www.hjackson.org/mt/mt-tb.cgi/60

Leave a comment

About this Entry

This page contains a single entry by Harry published on August 22, 2004 9:30 PM.

New RSS Job Feed was the previous entry in this blog.

PDF Tool is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Powered by Movable Type 4.01