Test counts and vim

tomhukins on 2010-07-01T08:05:23

My current favourite vim trick when writing tests in Perl is CTRL-A.

My tests contain a line near the top that looks like use Test::More tests => 12 where my test suite has 12 tests. I move my cursor over the number 12 and type mc which sets a mark labelled "c" for test count.

Then, if I write 5 new tests, I type `c (backtick c) to jump to my test count, then 5 CTRL-A to increment my test count by 5. Finally, `` (2 backticks) takes me back to where I was last editing.

If I remove tests, I use CTRL-V instead of CTRL-A to decrement the test count.


Nice!

mir on 2010-07-01T13:36:10

I did not know about CTRL-A, so thanks for the tip. BTW on my gvim, I need CTRL-x to decrement.

Re:Nice!

tomhukins on 2010-07-01T14:29:38

Yes, I use CTRL-X too, but I got confused when writing this. I guess touch typing has some disadvantages..

Thanks for ``

Bernhard on 2010-07-02T09:31:08

Thanks for this tip. I knew about CTRL-A, but the `` (2 backticks) were new to me.