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 231 remaining solutions by signing in and submitting your own entry
#232 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

232 active golfers, 624 entries

Leaderboard (lowest score wins):
14
#61 - Lory / @Lory46845742

12/10/2019 at 02:34PM

14
#62 - Miłosz Łakomy / @foobar01123

02/23/2020 at 04:35AM

14
#63 - Jung Yeon Park / @park_jungy

08/09/2021 at 01:17PM

14
#64 - vim_maxter / @MaxterVim

09/20/2021 at 06:00AM

14
#65 - Salvador Tojo Quintela / @SalvadorTojo

10/12/2021 at 10:32AM

14
#66 - Jean George / @JeanGeo20504212

03/30/2022 at 10:31AM

14
#67 - russellzhaomao / @russellzhaomao

05/28/2022 at 01:27PM

14
#68 - Qing Liu / @poeminlash

07/23/2022 at 01:50AM

14
#69 - Zion Park / @zionpark93

01/09/2023 at 03:39AM

14
#70 - James Reading / @bowly_jim

04/18/2023 at 08:29PM

14
#71 - Peppa Pig / @PeppaPi95550250

04/08/2024 at 01:59AM

14
#72 - nickGPT / @nickandbro

08/29/2024 at 12:03AM

14
#73 - KoroneListener / @KoroneListener

09/04/2024 at 07:11AM

15
#74 - Marian Schubert / @MarianSchubert

12/29/2010 at 04:10PM

15
#75 - Lee Jarvis / @lee_jarvis

12/29/2010 at 04:20PM

15
#76 - Aaron Bull Schaefer / @elasticdog

12/29/2010 at 04:38PM

15
#77 - Daniel Chcouri / @daniel_chcouri

12/29/2010 at 04:54PM

15
#78 - Steve Morrow / @yawmark

12/29/2010 at 06:19PM

15
#79 - Adam Pohorecki / @apohorecki

12/29/2010 at 08:12PM

15
#80 - kuhout / @kuhout

12/29/2010 at 08:19PM

15
#81 - uuu / @uu59

12/29/2010 at 10:05PM

15
#82 - Douglas Stockwell / @dstockwell

12/30/2010 at 01:21AM

15
#83 - Addisu Taddese / @azeey

12/30/2010 at 07:37AM

15
#84 - Ben Lenarts / @benlenarts

12/30/2010 at 11:18AM

15
#85 - Israel Chauca F. / @Raimondi

01/01/2011 at 09:35PM

15
#86 - Ben Brown / @benofbrown

01/09/2011 at 12:16PM

15
#87 - Francisco Dibar / @frandibar

01/14/2011 at 03:14AM

15
#88 - duckdalbe / @duckdalbe

01/14/2011 at 12:23PM

15
#89 - Pete Johns / @johnsyweb

01/15/2011 at 02:57AM

15
#90 - h_east (トロッコ6個) / @h_east

01/16/2011 at 09:02AM