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

1405 active golfers, 5714 entries

Leaderboard (lowest score wins):
40
#721 - Joel Gärtner / @Jeerok

01/14/2014 at 06:44PM

40
#722 - John Amicangelo / @AmicangeloJohn

01/21/2014 at 06:15PM

40
#723 - Arnaud Brousseau / @arnaudbrousseau

02/03/2014 at 07:41AM

40
#724 - (ノ●ヮ●)ノ*:・゚✧ / @jaredrnorman

02/08/2014 at 06:23PM

40
#725 - barnabaguy / @barnabaguy

02/17/2014 at 09:23PM

40
#726 - Jean-PhilippeBurelle / @jpburelle

03/02/2014 at 04:38AM

40
#727 - Chad / @chadskeeters

04/04/2014 at 03:51AM

40
#728 - madka / @lachrimae_pavan

08/04/2014 at 04:01PM

40
#729 - Jakob / @jajob

10/13/2014 at 05:34PM

40
#730 - Nicolas Dascanio / @NicoDascanio

11/25/2014 at 08:25PM

40
#731 - eirc / @eirc

01/24/2015 at 01:33PM

40
#732 - Ala' Ibrahim / @alaa_ibrahim

03/10/2015 at 10:32AM

40
#733 - Robin Moussu / @robin_moussu

03/30/2015 at 08:03AM

40
#734 - alex / @alexAngle8

08/23/2015 at 03:06PM

40
#735 - Dinesh Bhosale / @MrDineshBhosale

03/30/2016 at 07:57PM

40
#736 - Tom / @CronutFacts

05/21/2016 at 01:45AM

40
#737 - niels aamloos / @AamloosNiels

05/28/2016 at 01:10PM

40
#738 - Ryan van Rensburg / @rdvr001

07/21/2016 at 09:35AM

40
#739 - 赤佐田奈葉 / @akasatanaha_

06/26/2018 at 02:58AM

40
#740 - Diane Cochran / @DianeOfTheMoon

12/22/2018 at 09:57PM

40
#741 - Grant / @grant_7788

04/28/2019 at 02:42PM

40
#742 - vimgolfer24271 / @vimgolfer24271

05/13/2019 at 08:22AM

40
#743 - Chester Yap / @Chest_ErYap

07/27/2019 at 01:44PM

40
#744 - Baine Wedlock / @BaineWedlock

09/21/2019 at 02:34PM

40
#745 - vimgolfer / @vimgolfer7

10/04/2019 at 12:25AM

41
#746 - Benoit D / @Anbcorp

12/29/2010 at 04:07PM

41
#747 - dcbaok / @dcbaok

12/30/2010 at 06:05PM

41
#748 - Cartney McLennon / @mepsi_pax

01/05/2011 at 09:49PM

41
#749 - Chuck Phillips / @chuckphillips

01/07/2011 at 01:54AM

41
#750 - Bradly Feeley / @bradly

01/11/2011 at 12:14AM