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
#91 - h_east (トロッコ6個) / @h_east

01/16/2011 at 09:02AM

15
#92 - Andrey A. Ugolnik / @andreyugolnik

01/20/2011 at 02:02AM

15
#93 - Thomas Schönwälder / @Masei1988

01/22/2011 at 09:52PM

15
#94 - vg / @vimgolfer

01/29/2011 at 03:11AM

15
#95 - Wesley Wong / @wesleymwwong

01/30/2011 at 10:40AM

15
#96 - Ravil Bayramgalin / @brainopia

02/12/2011 at 05:01PM

15
#97 - Eivind Jahren / @HaskellElephant

02/21/2011 at 05:37PM

15
#98 - Dragan Cvetinovic / @kawkafi

05/08/2011 at 06:24PM

15
#99 - Junfeng / @junfeng

07/17/2011 at 02:16PM

15
#100 - Jim Infield / @jinfield

07/20/2011 at 11:39PM

15
#101 - Tyler Wymer / @twymer

10/14/2011 at 12:08AM

15
#102 - Trevor Powell / @DoomedBunnies

11/29/2011 at 06:50AM

15
#103 - Xavier Nayrac / @lkdjiin

12/30/2011 at 10:51AM

15
#104 - GiaNU / @sgianazza

02/04/2012 at 12:07AM

15
#105 - Zeh Rizzatti / @zehrizzatti

02/09/2012 at 02:04AM

15
#106 - Javier Blanco / @jbgutierrez

02/09/2012 at 11:06PM

15
#107 - Daumantas / @dbaltrus

05/03/2012 at 06:08AM

15
#108 - Michael / @patheticpat

12/17/2012 at 10:41PM

15
#109 - xavier kt / @xav_kt

02/05/2013 at 01:14AM

15
#110 - cj / @cj01101

08/20/2013 at 10:35PM

15
#111 - Kyle Travis / @kmakai

05/17/2014 at 05:58AM

15
#112 - CJ Avilla / @cjav_dev

11/18/2014 at 05:23PM

15
#113 - Josu Oyanguren / @josuoyanguren

12/19/2014 at 12:49PM

15
#114 - William Ott / @oddalot

04/15/2015 at 04:19PM

15
#115 - Ben Hill / @KaizenSoze70

05/31/2016 at 12:15PM

15
#116 - Mihai / @mihaicristiant

02/25/2019 at 07:44AM

15
#117 - serent / @serent

04/03/2019 at 09:48PM

15
#118 - Nick Yeow / @nickyeow

05/23/2019 at 02:27PM

15
#119 - Ryan Nevius / @ryannevius

03/20/2020 at 07:08AM

15
#120 - Brandon / @Brandon10678836

08/31/2022 at 11:39PM