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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
46
#991 - Dab Padilla / @dabit

01/02/2011 at 05:02AM

46
#992 - Kentarito / @elkentarito

01/03/2011 at 01:23AM

46
#993 - Zsolt Botykai / @botykai_zsolt

01/04/2011 at 10:03AM

46
#994 - erik hinton / @erikhinton

01/04/2011 at 10:06PM

46
#995 - Wonha Ryu / @beingryu

01/11/2011 at 06:19AM

46
#996 - szetobo / @szetobo

01/12/2011 at 02:32AM

46
#997 - David Mohundro / @drmohundro

01/20/2011 at 09:58PM

46
#998 - Basir Rajendra / @basirraj

01/25/2011 at 01:50AM

46
#999 - Aaron Kalin / @martinisoft

03/01/2011 at 01:44AM

46
#1000 - Mikhail Korepanov / @PanyaKor

06/12/2011 at 11:35PM

46
#1001 - Jam / @jam00_bcn

06/18/2011 at 04:33PM

46
#1002 - Sebastian Morr / @blinry

06/21/2011 at 02:31PM

46
#1003 - 42hitchhiker / @42hitchhiker

07/04/2011 at 08:10PM

46
#1004 - Mike Grouchy / @mgrouchy

08/23/2011 at 02:20PM

46
#1005 - Phillip Gomez / @phillipgomez

03/02/2012 at 05:49PM

46
#1006 - Edmundo Martinez / @edmundonm

08/11/2012 at 10:22PM

46
#1007 - Fergal Gribben / @fergalgribben

08/21/2012 at 10:51PM

46
#1008 - Alec Chen / @alec929

11/03/2012 at 02:29PM

46
#1009 - makala noble / @mnoble01

11/13/2012 at 10:23AM

46
#1010 - Serge Yefimov / @denver_14

12/29/2012 at 08:19AM

46
#1011 - Tuonenpoika / @tuonenpoika

12/31/2012 at 11:44PM

46
#1012 - Daniel Champion / @DanielChampion3

01/06/2013 at 12:57AM

46
#1013 - Jesse Nazario / @JesseNazario

04/16/2013 at 11:37AM

46
#1014 - Bitt Faulk / @bittfaulk

04/30/2013 at 05:17PM

46
#1015 - Derek Salerno / @DerekSalerno

05/26/2013 at 07:50PM

46
#1016 - Steffen Dienst / @sdienst

07/23/2013 at 11:26AM

46
#1017 - teo danciu / @teozaurus

10/17/2013 at 02:03AM

46
#1018 - Justin Knag / @justinknag

08/28/2014 at 12:14PM

46
#1019 - Herr Oppermann / @HerrOppermann

09/17/2014 at 05:00PM

46
#1020 - Mohamad Ayyash / @mkayyash

09/19/2014 at 12:02AM