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):
14
#31 - Rod Knowlton / @codelahoma

05/27/2012 at 04:17AM

14
#32 - Urtica dioica / @udioica

05/30/2012 at 01:09AM

14
#33 - Kerson Hsiao / @KersonHsiao

07/30/2012 at 10:05AM

14
#34 - Conner McDaniel / @connermcd

09/19/2012 at 02:18AM

14
#35 - Vim rocks / @vimrocks

10/08/2012 at 06:54PM

14
#36 - Hubba / @HubbaBubbaFett

12/18/2012 at 06:27PM

14
#37 - a24f0600 / @a24f0600

01/11/2013 at 04:30PM

14
#38 - Tyler / @tylerbindon

04/01/2013 at 03:19AM

14
#39 - Marco Hinz / @_mhinz_

05/23/2013 at 08:32AM

14
#40 - Bradd Szonye / @bszonye

07/15/2013 at 05:38AM

14
#41 - Petro Тrouq / @zulolosi

07/19/2013 at 07:36PM

14
#42 - Kevin McGladdery / @run_kmc

07/31/2013 at 07:00AM

14
#43 - brett / @brettyukich

09/22/2013 at 09:15PM

14
#44 - Stefan Schmidt / @stafue

12/06/2013 at 04:28PM

14
#45 - Joonas Pihlajamaa / @jokkebk

02/20/2014 at 08:43AM

14
#46 - Xelrifos / @Xelrifos

02/23/2014 at 12:49PM

14
#47 - John Braxler / @braxler

05/02/2014 at 04:35PM

14
#48 - LC / @leeren

08/10/2014 at 07:43AM

14
#49 - Michael Comerford / @MComerford1

09/26/2014 at 11:56AM

14
#50 - kimber gonzalez / @kimberlycreates

02/06/2015 at 03:16PM

14
#51 - Felix / @DoubleFelix_

02/24/2015 at 08:02AM

14
#52 - pftb12345 / @pftb12345

04/13/2015 at 11:45AM

14
#53 - Matt / @mcr05

07/14/2015 at 11:31AM

14
#54 - Jon Krause / @jkrause314

12/19/2015 at 08:50AM

14
#55 - Martin Tõnusoo / @martintonusoo

07/26/2016 at 11:28PM

14
#56 - Daniel / @Daniel00288663

04/03/2017 at 01:17PM

14
#57 - Turkey Man / @lvturkeyman

11/26/2017 at 09:57AM

14
#58 - BarbaJol / @drpproteus

01/04/2018 at 01:53PM

14
#59 - Evgeny`s Kindle / @EvgenyKindle

05/03/2018 at 06:50AM

14
#60 - james_bunch / @james_bunch

04/03/2019 at 01:02AM