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

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 234 remaining solutions by signing in and submitting your own entry
#235 Ben Bayard / @partyfists - Score: 174 - 12/29/10 @ 18:47
<Down><Down><Down><Down><Down><Down><Down><Down><Down><Down><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><BS><Right>i<BS> then<Down><Left><Left><Left><Left><BS>theb=<BS><BS>m<BS>n<Left><Left><Left><Left><Left><Right> !Q<BS><BS><Esc>:wq<CR>

0 comments


Created by: @lee_jarvis

235 active golfers, 634 entries

Leaderboard (lowest score wins):
19
#181 - Luc Stepniewski / @lstep

12/29/2010 at 03:56PM

19
#182 - Adam / @arboooz

12/29/2010 at 09:19PM

19
#183 - Roland Crosby / @roooooland

12/30/2010 at 08:58AM

19
#184 - __anders__ / @__anders__

12/30/2010 at 01:39PM

19
#185 - Adam Williams / @aiwilliams

12/30/2010 at 03:48PM

19
#186 - Yannick LM / @yanicklm

12/30/2010 at 05:12PM

19
#187 - Guillaume Bonnoron / @gbonnoron

12/30/2010 at 05:36PM

19
#188 - Alain Gilbert / @alain_gilbert

12/30/2010 at 09:02PM

19
#189 - Guten / @GutenYe

12/31/2010 at 01:14AM

19
#190 - garygordon / @garygordon

12/31/2010 at 01:53AM

19
#191 - larsd / @larsd

12/31/2010 at 09:31PM

19
#192 - Casey W Crites / @caseycrites

12/31/2010 at 09:38PM

19
#193 - Dezső Zoltán / @zakiazigazi

01/22/2011 at 08:56AM

19
#194 - Tim Andersson / @Boerworz

04/19/2011 at 10:41PM

19
#195 - Jyun-Fan Tsai / @fakecolor

02/11/2012 at 05:06AM

19
#196 - Edgar Gonzalez / @gonzedge

03/02/2012 at 06:11AM

19
#197 - r. / @rmarvie

12/20/2014 at 09:43PM

20
#198 - Asís García / @asischao

12/29/2010 at 07:40PM

20
#199 - David Rivers / @davidmrivers

12/29/2010 at 09:09PM

20
#200 - Unsouled / @unsouled0

12/31/2010 at 01:27AM

20
#201 - gruolin / @gruolin

11/05/2011 at 07:37AM

20
#202 - Omer Jakobinsky / @OmerJ

04/21/2012 at 04:43PM

20
#203 - sathish316 / @sathish316

11/19/2012 at 09:20AM

20
#204 - Brian / @wyantb_reader

06/26/2014 at 10:51AM

21
#205 - Dan / @opello

12/29/2010 at 03:31PM

21
#206 - Kornél Lugosi / @Coornail

12/29/2010 at 04:40PM

21
#207 - manlon / @manlon

12/29/2010 at 06:25PM

21
#208 - DJ Adams / @qmacro

12/29/2010 at 08:08PM

21
#209 - alexscott / @4l3xsc0tt

12/30/2010 at 01:59AM

21
#210 - Daniel Harrington / @rubiii

12/10/2011 at 07:58PM