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 210 remaining solutions by signing in and submitting your own entry
#211 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

211 active golfers, 557 entries

Leaderboard (lowest score wins):
18
#151 - John Ford / @GhettoCode

02/07/2012 at 12:37PM

18
#152 - bburky / @bburky

02/24/2012 at 04:14AM

18
#153 - うえっち / @uh_tomo

12/05/2012 at 06:37AM

18
#154 - Oliver Christ / @0liverChrist

10/03/2013 at 08:54PM

18
#155 - James / @Dronak

09/21/2014 at 02:46AM

18
#156 - ltn614 / @ltn614

09/27/2015 at 06:35AM

18
#157 - Gurukandhamoorthi / @Gurukandhamoor1

07/26/2017 at 03:38PM

19
#158 -  Ikhsan Maulana / @ixandidu

12/29/2010 at 03:10PM

19
#159 - Luc Stepniewski / @lstep

12/29/2010 at 03:56PM

19
#160 - Adam / @arboooz

12/29/2010 at 09:19PM

19
#161 - Roland Crosby / @roooooland

12/30/2010 at 08:58AM

19
#162 - __anders__ / @__anders__

12/30/2010 at 01:39PM

19
#163 - Adam Williams / @aiwilliams

12/30/2010 at 03:48PM

19
#164 - Yannick LM / @yanicklm

12/30/2010 at 05:12PM

19
#165 - Guillaume Bonnoron / @gbonnoron

12/30/2010 at 05:36PM

19
#166 - Alain Gilbert / @alain_gilbert

12/30/2010 at 09:02PM

19
#167 - Guten / @GutenYe

12/31/2010 at 01:14AM

19
#168 - garygordon / @garygordon

12/31/2010 at 01:53AM

19
#169 - larsd / @larsd

12/31/2010 at 09:31PM

19
#170 - Casey W Crites / @caseycrites

12/31/2010 at 09:38PM

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

01/22/2011 at 08:56AM

19
#172 - Tim Andersson / @Boerworz

04/19/2011 at 10:41PM

19
#173 - Jyun-Fan Tsai / @fakecolor

02/11/2012 at 05:06AM

19
#174 - Edgar Gonzalez / @gonzedge

03/02/2012 at 06:11AM

19
#175 - r. / @rmarvie

12/20/2014 at 09:43PM

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

12/29/2010 at 07:40PM

20
#177 - David Rivers / @davidmrivers

12/29/2010 at 09:09PM

20
#178 - Unsouled / @unsouled0

12/31/2010 at 01:27AM

20
#179 - gruolin / @gruolin

11/05/2011 at 07:37AM

20
#180 - Omer Jakobinsky / @OmerJ

04/21/2012 at 04:43PM