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):
16
#121 - Brent Carmer / @brent_carmer

04/12/2013 at 05:42AM

16
#122 - Quota / @Quotad

05/05/2014 at 09:30AM

16
#123 - Matt Robbins / @mcrmfc

11/14/2014 at 11:32PM

16
#124 - Walker Boh / @walker_boh

11/17/2015 at 12:23PM

16
#125 - Brandon Blakeley / @zkelvin

11/25/2017 at 06:57AM

17
#126 - Josh Weinberg / @jcweinberg

12/30/2010 at 05:15AM

17
#127 - Matt Tarbit / @mtarbit

01/09/2011 at 12:20AM

17
#128 - Rolf K. / @mindleftbody

06/17/2011 at 02:12PM

17
#129 - Arto Vuori / @dhpe

08/30/2012 at 09:47PM

17
#130 - Mike Marion / @mikejmarion

02/03/2014 at 11:56PM

17
#131 - Rathrio / @Rathrio

01/19/2015 at 05:35PM

17
#132 - Martin Liberg / @marreman

02/07/2015 at 06:31PM

17
#133 - Adrien Fabre / @statox42

05/25/2015 at 12:45PM

18
#134 - Dhruva Sagar / @dhruvasagar

12/29/2010 at 03:52PM

18
#135 - Vojtech Hyza / @vhyza

12/29/2010 at 04:35PM

18
#136 - Felipe Nakandakari / @fenak

12/29/2010 at 04:50PM

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

12/29/2010 at 05:23PM

18
#138 - Simon Edwardsson / @_SimEdw_

12/29/2010 at 05:43PM

18
#139 - Adam Bachman / @abachman

12/29/2010 at 06:32PM

18
#140 - Glenn / @spamcow_moo

12/29/2010 at 06:45PM

18
#141 - clint tseng / @cxlt

12/29/2010 at 07:16PM

18
#142 - nooodl / @nooodl

12/30/2010 at 11:36AM

18
#143 - Oriol Gual / @oriolgual

12/30/2010 at 01:42PM

18
#144 - Stephen Celis / @stephencelis

12/30/2010 at 02:56PM

18
#145 - Rune Botten / @runeb

12/31/2010 at 01:40AM

18
#146 - drio / @drio

01/02/2011 at 02:27PM

18
#147 - RoboKiller18000 / @robokiller18000

01/07/2011 at 02:33PM

18
#148 - Toto l'haricot / @nico_le_terribl

01/09/2011 at 10:46PM

18
#149 - Matthieu Honel / @ocus

01/29/2011 at 12:55PM

18
#150 - mightyfoo / @mightyfoo

05/26/2011 at 02:21AM