Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Ovid (2709)

Ovid
  (email not shown publicly)
http://publius-ovidius.livejournal.com/
AOL IM: ovidperl (Add Buddy, Send Message)

Stuff with the Perl Foundation. A couple of patches in the Perl core. A few CPAN modules. That about sums it up.

Journal of Ovid (2709)

Monday March 26, 2007
09:11 AM

My new vim command

[ #32795 ]

Thanks to smylers for helping me work out the new vim command I have.

The problem is that when I'm working on Test::Class tests, I often only want to run one test method. So I wrote ,tc0 (test class off) and ,tc1 (test class on) mappings:

noremap ,tc0 :%s/^\s*sub\s\+\w\+[^:]*:.*Test.*{.*$/& ;return;<cr>
noremap ,tc1 :%s/^\v(\s*sub\s+\w+[^:]*:.*Test.*\{.*) ;return;/\1/<cr>

Those look OK (the second one is subtly different syntax as I'm in the process of rewriting this), but there's a bug. Basically, the first one adds a 'return' at the beginning of test methods, forcing them to skip. I manually remove the return for the test method I want and when I'm done, I run ,tc1 to remove those return statements. However, they break if I have any setup, teardown, startup or shutdown methods. However, before I fix that, I wanted to solve a long-standing problem I have. I keep changing my .vimrc and forgetting to source that file. The following line in your .vimrc will automatically source it once you've written out any changes.

" automatically source the .vimrc file if I change it
au! BufWritePost .vimrc source %

Update: It looks like the vim mappings I wanted were as follows:

noremap ,tc0 :%s/^\v\s*sub\s+\w+[^:]*:.*Tests?\s*(\(\s*(no_plan\|\d+)\s*\))?\s*\{.*$/& ;return;<cr>
noremap ,tc1 :%s/^\v(\s*sub\s+\w+[^:]*:.*Test.*\{.*) ;return;/\1/<cr>

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.