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):
15
#91 - Zeh Rizzatti / @zehrizzatti

02/09/2012 at 02:04AM

15
#92 - Javier Blanco / @jbgutierrez

02/09/2012 at 11:06PM

15
#93 - Daumantas / @dbaltrus

05/03/2012 at 06:08AM

15
#94 - Michael / @patheticpat

12/17/2012 at 10:41PM

15
#95 - xavier kt / @xav_kt

02/05/2013 at 01:14AM

15
#96 - cj / @cj01101

08/20/2013 at 10:35PM

15
#97 - Kyle Travis / @kmakai

05/17/2014 at 05:58AM

15
#98 - w1zeman1p / @wizemanip

11/18/2014 at 05:23PM

15
#99 - Josu Oyanguren / @josuoyanguren

12/19/2014 at 12:49PM

15
#100 - William Ott / @oddalot

04/15/2015 at 04:19PM

15
#101 - Ben Hill / @KaizenSoze70

05/31/2016 at 12:15PM

15
#102 - Mihai / @mihaicristiant

02/25/2019 at 07:44AM

15
#103 - serent / @serent

04/03/2019 at 09:48PM

15
#104 - Nick Yeow / @nickyeow

05/23/2019 at 02:27PM

16
#105 - Fer Enaf / @0x00C0FFEE

12/29/2010 at 03:49PM

16
#106 - Utkarsh Kukreti / @utkarshkukreti

12/29/2010 at 05:04PM

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

12/29/2010 at 06:29PM

16
#108 - Nick Stenning / @nickstenning

12/29/2010 at 09:39PM

16
#109 - Vítek Burda / @n0name2

12/29/2010 at 11:11PM

16
#110 - Henrik Nyh / @henrik

12/30/2010 at 12:24AM

16
#111 - Ricardo Mendes / @locks

12/30/2010 at 03:14AM

16
#112 - Isac Sacchi e Souza / @isacssouza

12/31/2010 at 10:13PM

16
#113 - Petro Verkhogliad / @vpetro

01/17/2011 at 09:50PM

16
#114 - Anton / @al_alley

07/29/2011 at 08:38PM

16
#115 - Dave / @zzdave13

07/31/2011 at 02:37PM

16
#116 - David / @dpa_92

08/02/2011 at 07:41AM

16
#117 - Christopher Brew / @Seph1rothVII

01/31/2012 at 09:59PM

16
#118 - Terje Larsen / @terlars

02/21/2012 at 01:20PM

16
#119 - Nolen Royalty / @NolenRoyalty

04/21/2012 at 02:28AM

16
#120 - Yann Moisan / @YannMoisan

01/24/2013 at 11:25AM