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

1414 active golfers, 5742 entries

Leaderboard (lowest score wins):
37
#451 - Toto l'haricot / @nico_le_terribl

01/10/2011 at 10:20PM

37
#452 - Steve Morrow / @yawmark

01/13/2011 at 03:40AM

37
#453 - deris / @deris0126

01/26/2011 at 05:40PM

37
#454 - Luke Randall / @luke_randall

02/08/2011 at 03:30PM

37
#455 - Tim Harper / @timcharper

03/17/2011 at 07:58PM

37
#456 - Yannis Chatzimichos / @feedward

04/13/2011 at 12:57AM

37
#457 - Damian Dawber / @damian6970

05/30/2011 at 08:46PM

37
#458 - Alan Peabody / @alanpeabody

06/03/2011 at 03:31AM

37
#459 - rhkwdamicjhdf / @rhkwdamicjhdf

06/08/2011 at 06:02AM

37
#460 - Peter Anselmo / @peter_anselmo

06/24/2011 at 08:59PM

37
#461 - Eric Gerlach / @egerlach

07/17/2011 at 05:42AM

37
#462 - Neil / @spameldoon

08/20/2011 at 11:37PM

37
#463 - Carlos Yaconi H. / @cyaconi

12/06/2011 at 03:19PM

37
#464 - Rambominator / @Rambominator

12/10/2011 at 09:31PM

37
#465 - sol / @dichotomizer

12/14/2011 at 06:06PM

37
#466 - fred6 / @_fred6

12/19/2011 at 12:32AM

37
#467 - Xavier Nayrac / @lkdjiin

12/28/2011 at 07:09PM

37
#468 - Daniel Cohen / @danielissimo

02/07/2012 at 05:38PM

37
#469 - Drew Benedetti / @cnorsl

02/16/2012 at 07:39PM

37
#470 - 無ん垢の叫び / @john_ababa

02/21/2012 at 01:33PM

37
#471 - Dan Herbert / @pocketninja_au

04/04/2012 at 05:21AM

37
#472 - jDeveloper / @jDevEE

04/19/2012 at 12:21AM

37
#473 - Christian Gaida / @chgaida

05/06/2012 at 09:12PM

37
#474 - Tom Sisk / @TomSisk

06/24/2012 at 01:15PM

37
#475 - Brent Goldman / @bgold

07/31/2012 at 05:29PM

37
#476 - Reed Riley / @ReedRile

08/14/2012 at 12:51AM

37
#477 - deigen / @deigen0

08/28/2012 at 09:44AM

37
#478 - Roman Makarenko / @rmakarenko

09/30/2012 at 02:12PM

37
#479 - EwHejucAkyec / @EwHejucAkyec

10/02/2012 at 06:56AM

37
#480 - Serge Pirotte / @SergePirotte

10/18/2012 at 05:04PM