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

1370 active golfers, 5570 entries

Leaderboard (lowest score wins):
39
#601 - Dmitry Bashkatov / @dbashkatov

10/31/2011 at 08:37AM

39
#602 - Infertux / @Infertux

11/04/2011 at 04:45PM

39
#603 - Samnang Chhun / @samnangchhun

11/24/2011 at 06:48AM

39
#604 - Mislav Marohnić / @mislav

12/05/2011 at 05:27PM

39
#605 - Oscar Del Ben / @oscardelben

12/12/2011 at 01:00AM

39
#606 - Jey Balachandran / @jeybala

12/23/2011 at 02:36AM

39
#607 - Raúl Pedroche / @pedrocheisback

02/07/2012 at 08:34PM

39
#608 - demon.mhm / @demonmhm

02/18/2012 at 06:37PM

39
#609 - Lukas / @cast3r

03/11/2012 at 12:37AM

39
#610 - learninghang / @learninghang

04/14/2012 at 10:27AM

39
#611 - James Bell / @sarcainian

05/05/2012 at 11:31PM

39
#612 - Tyler B / @DuderB

05/10/2012 at 06:41PM

39
#613 - Andrey Yankin / @YankinAndrey

07/20/2012 at 10:46AM

39
#614 - Pau C. / @Pau_Compte

07/25/2012 at 07:09PM

39
#615 - Glen / @Glen_S

07/31/2012 at 06:16AM

39
#616 - Arto Vuori / @dhpe

08/29/2012 at 09:28PM

39
#617 - Marcin Sza / @coot_

09/24/2012 at 01:28PM

39
#618 - Gregor Schmidt / @schmidtwisser

09/27/2012 at 09:15AM

39
#619 - Nathan Eror / @neror

10/17/2012 at 09:15PM

39
#620 - Michael / @Amormzee

12/17/2012 at 03:14PM

39
#621 - Joel Elkins / @dice_tea

03/11/2013 at 03:30PM

39
#622 - n2o4 / @scatotonic

03/16/2013 at 01:55PM

39
#623 - Goran Petrovity / @nasdukar

04/07/2013 at 09:40AM

39
#624 - Raphaël Pierquin / @perafoo

04/09/2013 at 02:44PM

39
#625 - David Gibson / @dgibson_

04/30/2013 at 11:58AM

39
#626 - Nathan / @NathanHarperoni

07/16/2013 at 08:16PM

39
#627 - Tullio Facchinetti / @toolleeo

08/02/2013 at 12:25PM

39
#628 - Alexander / @usr_noid

08/15/2013 at 08:20PM

39
#629 - Francois Picalausa / @fpicalausa

08/22/2013 at 04:49PM

39
#630 - Gwilym Kuiper / @gwilymk

09/24/2013 at 06:10PM