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):
14
#1 - Tom Adams / @holizz

12/29/2010 at 04:00PM

14
#2 - Leonard Chin / @lchin

12/29/2010 at 04:02PM

14
#3 - Indrek Juhkam / @indrekj

12/29/2010 at 04:04PM

14
#4 - Austin Taylor / @austintaylor

12/29/2010 at 08:09PM

14
#5 - Akira Matsuda / @a_matsuda

12/29/2010 at 08:31PM

14
#6 - Alex / @eskanete

12/30/2010 at 02:44PM

14
#7 - Matthew Draper / @_matthewd

12/31/2010 at 05:42PM

14
#8 - Mattiassich Ákos / @mattiassicha

01/02/2011 at 03:36PM

14
#9 - Wei Dai / @clvv42

01/02/2011 at 11:46PM

14
#10 - dominique pellé / @vimgolfisto

01/04/2011 at 11:40PM

14
#11 - Ujjwol Lamichhane / @Ujjwol

01/06/2011 at 01:16PM

14
#12 - Tim Chase / @gumnos

01/07/2011 at 11:54PM

14
#13 - Balkoth / @_Balkoth_

01/08/2011 at 06:09PM

14
#14 - Federico Galassi / @federicogalassi

01/17/2011 at 09:27PM

14
#15 - Oleg Roshupkin / @jjjahson

01/20/2011 at 04:11PM

14
#16 - xhtmlforum / @xhtmlforum

01/25/2011 at 03:20PM

14
#17 - dtennant / @dtennant

06/09/2011 at 03:30PM

14
#18 - Justin Love / @wondible

06/15/2011 at 04:31PM

14
#19 - Emile Swarts / @EmileSwarts

06/25/2011 at 11:42AM

14
#20 - not so punk :] / @notsopunk

06/26/2011 at 03:42AM

14
#21 - Sammasati / @sammasati0

07/16/2011 at 04:54PM

14
#22 - Andrey Ivanov / @Bytamine

08/11/2011 at 03:40PM

14
#23 - You-Siang Lin / @yslinnctu

11/30/2011 at 01:56PM

14
#24 - William Dunand / @wdunand

12/02/2011 at 06:48AM

14
#25 - Pei-Lun Lee / @ypcatw

01/08/2012 at 04:57AM

14
#26 - Renat Aksitov / @Korvin79

02/09/2012 at 08:25AM

14
#27 - Vasil Sakarov / @vsakarov

02/17/2012 at 08:42PM

14
#28 - じょんあば / @john_ababa

02/23/2012 at 10:07AM

14
#29 - kjrn / @kjrnleto

03/26/2012 at 06:41PM

14
#30 - Ales Guzik / @alesguzik

04/06/2012 at 12:59PM