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

1681 active golfers, 6866 entries

Leaderboard (lowest score wins):
28
#1 - KarateSnoopy / @KarateSnoopy

08/12/2024 at 08:50AM

32
#2 - Pei-Lun Lee / @ypcatw

12/16/2011 at 12:54PM

32
#3 - Tara Bass / @tara_bass

12/25/2011 at 05:58PM

32
#4 - John / @OneOhOneOhOneOh

02/05/2012 at 01:33AM

32
#5 - Zeh Rizzatti / @zehrizzatti

02/05/2012 at 07:25PM

32
#6 - Renat Aksitov / @Korvin79

02/07/2012 at 10:46PM

32
#7 - Darren Firth / @DarrenSFirth

02/20/2012 at 02:42AM

32
#8 - Federico Galassi / @federicogalassi

02/22/2012 at 06:48PM

32
#9 - Pawel Obrok / @mrYapee

03/13/2012 at 12:38PM

32
#10 - Ravil Bayramgalin / @brainopia

03/16/2012 at 01:03AM

32
#11 - Luismi Cavallé / @cavalle

04/06/2012 at 10:20PM

32
#12 - Son of Bongo / @bpcode

05/05/2012 at 03:48PM

32
#13 - VimGolfDzNrSQleot / @VimGolfDzNrSQle

05/10/2012 at 08:19PM

32
#14 - Sergey / @sav86

05/18/2012 at 01:58AM

32
#15 - Rod Knowlton / @codelahoma

05/26/2012 at 05:07PM

32
#16 - David / @ebonhand09

06/11/2012 at 11:59AM

32
#17 - skarrok / @skarrok

06/16/2012 at 11:23PM

32
#18 - Sylvain / @20vinW

07/08/2012 at 04:10PM

32
#19 - Taylor Rose / @trose89

07/13/2012 at 04:14AM

32
#20 - John Piasetzki / @jpiasetz

07/13/2012 at 06:50AM

32
#21 - James Davis / @tripvg

08/03/2012 at 07:12PM

32
#22 - Sean Griffin / @sgrif

08/12/2012 at 07:57PM

32
#23 - lwjef / @lwjef

08/13/2012 at 05:48AM

32
#24 - Kerson Hsiao / @KersonHsiao

08/13/2012 at 09:59AM

32
#25 - Nick Miller / @ItsMeNickMiller

08/13/2012 at 01:51PM

32
#26 - Charles Gordon / @liberalbias

08/22/2012 at 08:50PM

32
#27 - ninjay / @ninjaygolf

08/22/2012 at 09:17PM

32
#28 - Stanislav / @sseletskiy

08/23/2012 at 11:37AM

32
#29 - Alexey Baranov / @baranov0

08/24/2012 at 07:05AM

32
#30 - pixelpurist / @pixelpurist

08/31/2012 at 08:22PM