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 4d1a1c36567bac34a9000002

Reformat/Refactor a Golfer Class

A simple case of removing unneeded code and fixing broken indentation.

Start file
class Golfer
     def initialize; end # initialize
  def useless; end;
  
     def self.hello(a,b,c,d)
      puts "Hello #{a}, #{b}, #{c}, #{d}"
   end
end
End file
class Golfer
  def self.hello(*a)
    puts "Hello #{a.join(',')}"
  end
end

View Diff

2,7c2,4
<      def initialize; end # initialize
<   def useless; end;
<   
<      def self.hello(a,b,c,d)
<       puts "Hello #{a}, #{b}, #{c}, #{d}"
<    end
---
>   def self.hello(*a)
>     puts "Hello #{a.join(',')}"
>   end

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 1357 remaining solutions by signing in and submitting your own entry
#1358 Patrick Muldoon / @d00n - Score: 206 - 12/29/10 @ 15:12
<Esc>:<Up><Up><Up><Up><Up>g.<BS>/.*def.$<BS>*end.*/d<CR>:v/\S/f<BS>d<CR>fai*<Esc><Right><Right>cf))<Esc><Down><Left>i.join(',')<Esc>lldf:df"a"<Esc>=<Esc><Esc><BS><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>xxxxxi  <Down><Down><Esc>x<Up><Right>xx<Esc>:wq<CR>

0 comments


Created by: @igrigorik

1358 active golfers, 5527 entries

Leaderboard (lowest score wins):
32
#31 - Egor Laufer / @egor_laufer

09/14/2012 at 10:09PM

32
#32 - Conner McDaniel / @connermcd

09/18/2012 at 06:03AM

32
#33 - Lee Folkman / @leefolkman

09/18/2012 at 10:37PM

32
#34 - Nicholas Clark / @GitNick

09/18/2012 at 10:37PM

32
#35 - Victor Ramirez / @virako

09/30/2012 at 10:16PM

32
#36 - Daniel Wallace / @gtmanfred

10/06/2012 at 05:51AM

32
#37 - Vim rocks / @vimrocks

10/08/2012 at 10:17PM

32
#38 - Johan Isacsson / @JohanIsacsson

10/11/2012 at 10:53PM

32
#39 - Kate / @Arohanui

10/23/2012 at 06:43AM

32
#40 - Chris Patuzzo / @cpatuzzo

11/03/2012 at 09:17PM

32
#41 - Alex Podaras / @apodaras

11/07/2012 at 04:35PM

32
#42 - Aniket Schneider / @shaydwyrm

11/17/2012 at 06:58AM

32
#43 - Hubba / @HubbaBubbaFett

11/20/2012 at 08:34AM

32
#44 - Vimgolf Pikob / @vimgolfpikob

11/28/2012 at 12:17AM

32
#45 - Averell Dalton / @webtwoosucks

01/01/2013 at 11:23PM

32
#46 - Terry Ma / @terry_ma

01/06/2013 at 04:12AM

32
#47 - Kurt Robert Rudolph / @krudolph9

01/07/2013 at 12:28AM

32
#48 - Alexander Borysov / @ab99c5e2

01/15/2013 at 06:54PM

32
#49 - Kai Yuan / @kentyuan

02/21/2013 at 12:52PM

32
#50 - igoodrich / @igoodrich

03/02/2013 at 06:30AM

32
#51 - Nikolaj / @n1k0laj

03/14/2013 at 09:25AM

32
#52 - Petro Тrouq / @zulolosi

03/25/2013 at 11:21PM

32
#53 - Robottinosino / @Robottinosino

05/18/2013 at 06:52AM

32
#54 - wushexu / @wushexu

05/21/2013 at 01:34PM

32
#55 - Ingo / @ist3fani

06/01/2013 at 03:38PM

32
#56 - Adam Pohorecki / @apohorecki

06/12/2013 at 10:57AM

32
#57 - Jonáš Šerých / @serycjon

06/25/2013 at 09:58PM

32
#58 - Łukasz Bujakowski / @eggxtreme

06/28/2013 at 04:34PM

32
#59 - Eric Alexander / @ericalexander

07/10/2013 at 02:12AM

32
#60 - Bradd Szonye / @bszonye

07/10/2013 at 08:37PM