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

1308 active golfers, 5358 entries

Leaderboard (lowest score wins):
32
#1 - Pei-Lun Lee / @ypcatw

12/16/2011 at 12:54PM

32
#2 - Tara Bass / @tara_bass

12/25/2011 at 05:58PM

32
#3 - John / @OneOhOneOhOneOh

02/05/2012 at 01:33AM

32
#4 - Zeh Rizzatti / @zehrizzatti

02/05/2012 at 07:25PM

32
#5 - Renat Aksitov / @Korvin79

02/07/2012 at 10:46PM

32
#6 - Darren Firth / @DarrenSFirth

02/20/2012 at 02:42AM

32
#7 - Federico Galassi / @federicogalassi

02/22/2012 at 06:48PM

32
#8 - Pawel Obrok / @mrYapee

03/13/2012 at 12:38PM

32
#9 - Ravil Bayramgalin / @brainopia

03/16/2012 at 01:03AM

32
#10 - Luismi Cavallé / @cavalle

04/06/2012 at 10:20PM

32
#11 - Son of Bongo / @bpcode

05/05/2012 at 03:48PM

32
#12 - VimGolfDzNrSQleot / @VimGolfDzNrSQle

05/10/2012 at 08:19PM

32
#13 - Sergey / @sav86

05/18/2012 at 01:58AM

32
#14 - Rod Knowlton / @codelahoma

05/26/2012 at 05:07PM

32
#15 - David / @ebonhand09

06/11/2012 at 11:59AM

32
#16 - skarrok / @skarrok

06/16/2012 at 11:23PM

32
#17 - teocx / @teocx

07/08/2012 at 04:10PM

32
#18 - Taylor Rose / @trose89

07/13/2012 at 04:14AM

32
#19 - John Piasetzki / @jpiasetz

07/13/2012 at 06:50AM

32
#20 - James Davis / @tripvg

08/03/2012 at 07:12PM

32
#21 - Sean Griffin / @sgrif

08/12/2012 at 07:57PM

32
#22 - 刘玮 / @lwjef

08/13/2012 at 05:48AM

32
#23 - Kerson Hsiao / @KersonHsiao

08/13/2012 at 09:59AM

32
#24 - Nick Miller / @ItsMeNickMiller

08/13/2012 at 01:51PM

32
#25 - Charles Gordon / @liberalbias

08/22/2012 at 08:50PM

32
#26 - ninjay / @ninjaygolf

08/22/2012 at 09:17PM

32
#27 - Stanislav / @sseletskiy

08/23/2012 at 11:37AM

32
#28 - Alexey Baranov / @baranov0

08/24/2012 at 07:05AM

32
#29 - pixelpurist / @pixelpurist

08/31/2012 at 08:22PM

32
#30 - Augustin Trancart / @autra42

09/06/2012 at 02:48PM