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):
15
#121 - bounce114 / @bounce114

12/03/2024 at 08:45AM

16
#122 - Fer Enaf / @0x00C0FFEE

12/29/2010 at 03:49PM

16
#123 - Utkarsh Kukreti / @utkarshkukreti

12/29/2010 at 05:04PM

16
#124 - Jiří Stránský / @jistr

12/29/2010 at 06:29PM

16
#125 - Nick Stenning / @nickstenning

12/29/2010 at 09:39PM

16
#126 - Vítek Burda / @n0name2

12/29/2010 at 11:11PM

16
#127 - Henrik Nyh / @henrik

12/30/2010 at 12:24AM

16
#128 - Ricardo Mendes / @locks

12/30/2010 at 03:14AM

16
#129 - Isac Sacchi e Souza / @isacssouza

12/31/2010 at 10:13PM

16
#130 - Petro Verkhogliad / @vpetro

01/17/2011 at 09:50PM

16
#131 - Anton / @al_alley

07/29/2011 at 08:38PM

16
#132 - Dave / @zzdave13

07/31/2011 at 02:37PM

16
#133 - David / @dpa_92

08/02/2011 at 07:41AM

16
#134 - Christopher Brew / @Seph1rothVII

01/31/2012 at 09:59PM

16
#135 - Terje Larsen / @terlars

02/21/2012 at 01:20PM

16
#136 - Nolen Royalty / @NolenRoyalty

04/21/2012 at 02:28AM

16
#137 - Yann Moisan / @YannMoisan

01/24/2013 at 11:25AM

16
#138 - Brent Carmer / @brent_carmer

04/12/2013 at 05:42AM

16
#139 - Quota / @Quotad

05/05/2014 at 09:30AM

16
#140 - Matt Robbins / @mcrmfc

11/14/2014 at 11:32PM

16
#141 - Walker Boh / @walker_boh

11/17/2015 at 12:23PM

16
#142 - Brandon Blakeley / @zkelvin

11/25/2017 at 06:57AM

16
#143 - Pablo Acuna / @pacuna

10/21/2024 at 02:21AM

17
#144 - Josh Weinberg / @jcweinberg

12/30/2010 at 05:15AM

17
#145 - Matt Tarbit / @mtarbit

01/09/2011 at 12:20AM

17
#146 - Rolf K. / @mindleftbody

06/17/2011 at 02:12PM

17
#147 - Arto Vuori / @dhpe

08/30/2012 at 09:47PM

17
#148 - Mike Marion / @mikejmarion

02/03/2014 at 11:56PM

17
#149 - Rathrio / @Rathrio

01/19/2015 at 05:35PM

17
#150 - Martin Liberg / @marreman

02/07/2015 at 06:31PM