Accelerated testing

Ovid on 2003-08-28T18:25:08

The high level of Vim Fu here at work is simply astounding. While it will be a while before I even come close to the level of other people here, perhaps one of the most useful tricks I've found is this little line in my .vimrc: map ,r :! eval "./%" <cr>. (I don't know if that's the best syntax). Now, when I'm in command mode, ",r" will automatically run the program that I am editing (my test program, usually). My next hack will be to map a command to grind, my test program to run all tests.

Other things they do: when in a test, typing ",t" will run the test, ",gi" will go to the implementation (the module you're testing) and ",gt" will go back to the test for that module. It's marvelous how fast that speeds up testing.


Vim Mappings

chromatic on 2003-08-28T20:20:22

Care to share a few implementations? I'd be particularly interested in running the test file and filtering out all successes. (If that means writing to Test::Harness::Straps, so be it.)

Re:Vim Mappings

Ovid on 2003-08-28T21:00:25

They use custom test modules they wrote a while ago, so much of their implementation is based upon knowledge of their test modules and how they're structured. I haven't thought of a more generic way of doing it.

Unless I misunderstand you, perhaps a naive implementation in your .vimrc would be map ,t !eval "./%" | grep "^not"?

That will make the "not ok" show up and the error data is written to STDERR, so that also would not be filtered.

Re:Vim Mappings

Matts on 2003-08-29T08:09:12

Run the same using tv -q from Test::Verbose.

vim mappings

WebDragon on 2003-08-29T03:03:16

I'd be very interested in seeing some more of these useful vim mappings. I've been digging vim ever since I started playing with Red Hat back in Jan 2002, (and have gone so far as to install a Mac OS Classic version of vim on my PPC 7600 running OS 8.6)

I've gotten a lot of vim knowledge thanks to MetaCosm's IRC-style tutorial (which seems to be down at the moment but you can find it cached on google), and the #vim channel on irc.freenode.net, but fresh input from people that know some serious vim-fu would be greatly appreciated.

my favorite so far was a simple :r !date that inserts the current date string into my program so it's easy to fix the current release date when I make changes. However I recently learned a new trick... !!date overwrites the current line with the output of the date program, so I don't need to delete the previous line after the new one gets pasted in by :r

Even simpler

ethan on 2003-08-29T08:57:32

You don't even need the eval. I have two mappings for doing something with the current file:


      map ü :!perl -w %
      map ö :!perl -wc %


So 'ö' will syntax-check the current file (I hope the German umlauts will be visible to non-Germans as well). The disadvantage of that, I just realize, is that mine has the interpreter to use hardwired in and wont respect the she-bang line.

But indeed, vim is pretty amazing even though I am myself only scratching on the surface when using it. I think Rafael knows some really nifty tricks and has some of them on his webside.

Re:Even simpler

rafael on 2003-08-29T12:26:44

    :!./%
is even more simple. That's what I use ;-) although
    :new|r!./#
is also useful. (Quote the pipe with \ in maps.)

My favorite vim map is amazingly simple :
    vmap * y:let@/=@"<CR>n
Select a word or part of a word in visual mode, enter '*', and voilà, you're searching for this word.

Re:Even simpler

runrig on 2003-09-03T21:04:04

:!./%
Windows doesn't seem to like that, but specifying 'perl %' as the command does work. Either way, I really need to learn some vim; I'm still using it like it's plain vi.