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):
21
#211 - Woojung Kim 김우중 / @_kimwz

07/16/2013 at 04:30AM

21
#212 - Rory Smith / @alan0buchanan

09/20/2021 at 10:00PM

22
#213 - xHire / @xHire

12/29/2010 at 03:53PM

22
#214 - Josep Mª Bach / @txustice

12/29/2010 at 04:21PM

22
#215 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 04:29PM

22
#216 - Jan B. / @bracki

12/29/2010 at 10:38PM

22
#217 - akatz / @akatz

12/30/2010 at 07:12AM

22
#218 - Andrei Chirila / @andrei_chirila

12/30/2010 at 01:43PM

22
#219 - fuck you / @jerkassholeface

01/15/2011 at 12:51AM

23
#220 - Andrew McDonough / @andrewmcdonough

12/29/2010 at 07:02PM

24
#221 - tinco / @tinco

12/29/2010 at 03:16PM

24
#222 - Dan Smith / @untermrad

12/30/2010 at 10:19AM

24
#223 - Denis Odorcic / @denisodorcic

12/30/2010 at 06:27PM

25
#224 - Mike Adolphs / @mike_adolphs

12/29/2010 at 04:00PM

25
#225 - Sam Nardoni / @samnardoni

12/29/2010 at 04:05PM

26
#226 - Jurica / @Jurica34581259

12/11/2018 at 03:04PM

29
#227 - Benjamin Small / @ph1g

12/29/2010 at 04:02PM

30
#228 - Martin Ström / @haraldmartin

12/30/2010 at 12:19AM

30
#229 - Rustem B. / @_rustemb

07/31/2020 at 09:58AM

33
#230 - karmiq / @karmiq

12/29/2010 at 03:41PM

33
#231 - Boris Barroso / @borisb

12/29/2010 at 06:55PM

36
#232 - Tien Le / @tienlex

12/29/2010 at 05:27PM

59
#233 - Zhao Yao / @Lynch8080

12/31/2010 at 06:51PM

66
#234 - Shahor / @Shahor

12/29/2010 at 04:58PM

174
#235 - Ben Bayard / @partyfists

12/29/2010 at 06:47PM