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

232 active golfers, 624 entries

Leaderboard (lowest score wins):
18
#151 - Vojtech Hyza / @vhyza

12/29/2010 at 04:35PM

18
#152 - Felipe Nakandakari / @fenak

12/29/2010 at 04:50PM

18
#153 - August Ash, Inc. / @MN_Web_Design

12/29/2010 at 05:23PM

18
#154 - Simon Edwardsson / @_SimEdw_

12/29/2010 at 05:43PM

18
#155 - Adam Bachman / @abachman

12/29/2010 at 06:32PM

18
#156 - Glenn / @spamcow_moo

12/29/2010 at 06:45PM

18
#157 - clint tseng / @cxlt

12/29/2010 at 07:16PM

18
#158 - nooodl / @nooodl

12/30/2010 at 11:36AM

18
#159 - Oriol Gual / @oriolgual

12/30/2010 at 01:42PM

18
#160 - Stephen Celis / @stephencelis

12/30/2010 at 02:56PM

18
#161 - Rune Botten / @runeb

12/31/2010 at 01:40AM

18
#162 - drio / @drio

01/02/2011 at 02:27PM

18
#163 - RoboKiller18000 / @robokiller18000

01/07/2011 at 02:33PM

18
#164 - Toto l'haricot / @nico_le_terribl

01/09/2011 at 10:46PM

18
#165 - Matthieu Honel / @ocus

01/29/2011 at 12:55PM

18
#166 - mightyfoo / @mightyfoo

05/26/2011 at 02:21AM

18
#167 - John Ford / @GhettoCode

02/07/2012 at 12:37PM

18
#168 - bburky / @bburky

02/24/2012 at 04:14AM

18
#169 - うえっち / @uh_tomo

12/05/2012 at 06:37AM

18
#170 - Oliver Christ / @0liverChrist

10/03/2013 at 08:54PM

18
#171 - James / @Dronak

09/21/2014 at 02:46AM

18
#172 - ltn614 / @ltn614

09/27/2015 at 06:35AM

18
#173 - Gurukandhamoorthi / @Gurukandhamoor1

07/26/2017 at 03:38PM

18
#174 - rappenstein2 / @rappenstein2

01/12/2022 at 10:48PM

18
#175 - POSIX / @po6ix

01/23/2022 at 10:41AM

18
#176 - shahanavaz m / @shahanavazm

02/14/2022 at 12:09AM

19
#177 -  Ikhsan Maulana / @ixandidu

12/29/2010 at 03:10PM

19
#178 - Luc Stepniewski / @lstep

12/29/2010 at 03:56PM

19
#179 - Adam / @arboooz

12/29/2010 at 09:19PM

19
#180 - Roland Crosby / @roooooland

12/30/2010 at 08:58AM