Real Vim ninjas count every keystroke - do you?

Pick a challenge, fire up Vim, and show us what you got.

Changelog, Rules & FAQ, updates: @vimgolf, RSS.

Your VimGolf key: please sign in

$ gem install vimgolf
$ vimgolf setup
$ vimgolf put 4d1b4ac3c58eaa2a8a0005c2

Ruby 1.9 compat

Remember when Ruby supported `when <expr> :`? Well, it doesn't in 1.9, so let's make sure we use `then`, without ruining our lovely new hash syntax!

Start file
#!/usr/bin/env ruby

class Klass
  ITEMS = {
    foo: ["bar", "baz"],
    lorem: "ipsum",
  }

  def initialize(args)
    @item = case args.first
    when :foo, :bar: ITEMS[:foo][1]
    when :lorem    : ITEMS[:lorem]
    end
  end
end
End file
#!/usr/bin/env ruby

class Klass
  ITEMS = {
    foo: ["bar", "baz"],
    lorem: "ipsum",
  }

  def initialize(args)
    @item = case args.first
    when :foo, :bar then ITEMS[:foo][1]
    when :lorem     then ITEMS[:lorem]
    end
  end
end

View Diff

11,12c11,12
<     when :foo, :bar: ITEMS[:foo][1]
<     when :lorem    : ITEMS[:lorem]
---
>     when :foo, :bar then ITEMS[:foo][1]
>     when :lorem     then ITEMS[:lorem]

Solutions by @spamcow_moo:

Unlock 7 remaining solutions by signing in and submitting your own entry
Created by: @lee_jarvis

230 active golfers, 610 entries

Solutions by @spamcow_moo:
18
#154 - Glenn / @spamcow_moo

12/29/2010 at 06:45PM

21
#>202 - Glenn / @spamcow_moo

12/29/2010 at 06:40PM

22
#>210 - Glenn / @spamcow_moo

12/29/2010 at 06:38PM

23
#>214 - Glenn / @spamcow_moo

12/29/2010 at 06:20PM

26
#>220 - Glenn / @spamcow_moo

12/29/2010 at 06:19PM

42
#>227 - Glenn / @spamcow_moo

12/29/2010 at 06:17PM

60
#>228 - Glenn / @spamcow_moo

12/29/2010 at 06:15PM