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

1346 active golfers, 5485 entries

Leaderboard (lowest score wins):
37
#451 - Carlos Yaconi H. / @cyaconi

12/06/2011 at 03:19PM

37
#452 - Rambominator / @Rambominator

12/10/2011 at 09:31PM

37
#453 - sol / @dichotomizer

12/14/2011 at 06:06PM

37
#454 - fred6 / @_fred6

12/19/2011 at 12:32AM

37
#455 - Xavier Nayrac / @lkdjiin

12/28/2011 at 07:09PM

37
#456 - Daniel Cohen / @danielissimo

02/07/2012 at 05:38PM

37
#457 - Drew Benedetti / @cnorsl

02/16/2012 at 07:39PM

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

02/21/2012 at 01:33PM

37
#459 - Dan Herbert / @pocketninja_au

04/04/2012 at 05:21AM

37
#460 - jDeveloper / @jDevEE

04/19/2012 at 12:21AM

37
#461 - Christian Gaida / @chgaida

05/06/2012 at 09:12PM

37
#462 - Tom Sisk / @TomSisk

06/24/2012 at 01:15PM

37
#463 - Brent Goldman / @bgold

07/31/2012 at 05:29PM

37
#464 - Reed Riley / @ReedRile

08/14/2012 at 12:51AM

37
#465 - deigen / @deigen0

08/28/2012 at 09:44AM

37
#466 - Roman Makarenko / @rmakarenko

09/30/2012 at 02:12PM

37
#467 - EwHejucAkyec / @EwHejucAkyec

10/02/2012 at 06:56AM

37
#468 - Serge Pirotte / @SergePirotte

10/18/2012 at 05:04PM

37
#469 - Lieven Keersmaekers / @LievenKeersmaek

11/12/2012 at 08:06PM

37
#470 - Ray Lehtiniemi / @rayll

12/09/2012 at 11:28AM

37
#471 - a24f0600 / @a24f0600

12/13/2012 at 04:53PM

37
#472 - Gonzalo Arreche / @grilix

03/04/2013 at 07:14PM

37
#473 - Michael Kummer / @randompast

07/06/2013 at 07:03PM

37
#474 - Kevin McGladdery / @run_kmc

07/31/2013 at 05:24AM

37
#475 - Peter Johannson / @PeterJohannson

08/03/2013 at 08:07PM

37
#476 - Rémi Jézéquel / @Remjez

08/23/2013 at 12:03PM

37
#477 - Throw Away / @throwaway111111

10/02/2013 at 12:04AM

37
#478 - Paul Roberts / @psxpau1

10/13/2013 at 07:29AM

37
#479 - A. N. / @arez42

10/24/2013 at 06:16AM

37
#480 - Zach Kemp / @zvksf

12/13/2013 at 10:43PM