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):
40
#691 - xavier kt / @xav_kt

02/01/2013 at 04:19PM

40
#692 - Sean McKenna / @sean__mckenna

04/01/2013 at 09:13PM

40
#693 - Aaron Bieber / @aaronbieber

07/14/2013 at 11:12AM

40
#694 - fSchl / @FelixSchlitter

07/16/2013 at 07:51AM

40
#695 - Bruno Sutic / @brunosutic

07/18/2013 at 05:11AM

40
#696 - Heath Patterson / @HeathPatterson

08/09/2013 at 06:23PM

40
#697 - Sheng / @shenghis

08/25/2013 at 07:55PM

40
#698 - Alonso Torres / @alotor

09/23/2013 at 06:21PM

40
#699 - Volodimir Barna / @RobertoUA

09/30/2013 at 09:21AM

40
#700 - Sami Niiranen / @saminiir

10/13/2013 at 09:42AM

40
#701 - foo / @foo88832727

10/18/2013 at 03:16PM

40
#702 - Alexey Shmalko / @RasenDubi

11/04/2013 at 04:25PM

40
#703 - winterlight / @winterlight4

12/22/2013 at 10:40PM

40
#704 - Herrington Darkholme / @nonamesheep

12/27/2013 at 09:59AM

40
#705 - Joel Gärtner / @Jeerok

01/14/2014 at 06:44PM

40
#706 - John Amicangelo / @AmicangeloJohn

01/21/2014 at 06:15PM

40
#707 - Arnaud Brousseau / @arnaudbrousseau

02/03/2014 at 07:41AM

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

02/08/2014 at 06:23PM

40
#709 - barnabaguy / @barnabaguy

02/17/2014 at 09:23PM

40
#710 - Jean-PhilippeBurelle / @jpburelle

03/02/2014 at 04:38AM

40
#711 - Chad / @chadskeeters

04/04/2014 at 03:51AM

40
#712 - madka / @lachrimae_pavan

08/04/2014 at 04:01PM

40
#713 - Jakob / @jajob

10/13/2014 at 05:34PM

40
#714 - Nicolas Dascanio / @NicoDascanio

11/25/2014 at 08:25PM

40
#715 - eirc / @eirc

01/24/2015 at 01:33PM

40
#716 - Ala' Ibrahim / @alaa_ibrahim

03/10/2015 at 10:32AM

40
#717 - Robin Moussu / @robin_moussu

03/30/2015 at 08:03AM

40
#718 - alex / @alexAngle8

08/23/2015 at 03:06PM

40
#719 - Dinesh Bhosale / @MrDineshBhosale

03/30/2016 at 07:57PM

40
#720 - Tom / @CronutFacts

05/21/2016 at 01:45AM