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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
37
#511 - Eric Gerlach / @egerlach

07/17/2011 at 05:42AM

37
#512 - Neil / @spameldoon

08/20/2011 at 11:37PM

37
#513 - Carlos Yaconi H. / @cyaconi

12/06/2011 at 03:19PM

37
#514 - Rambominator / @Rambominator

12/10/2011 at 09:31PM

37
#515 - sol / @dichotomizer

12/14/2011 at 06:06PM

37
#516 - fred6 / @_fred6

12/19/2011 at 12:32AM

37
#517 - Xavier Nayrac / @lkdjiin

12/28/2011 at 07:09PM

37
#518 - Daniel Cohen / @danielissimo

02/07/2012 at 05:38PM

37
#519 - Drew Benedetti / @cnorsl

02/16/2012 at 07:39PM

37
#520 - じょんあば / @john_ababa

02/21/2012 at 01:33PM

37
#521 - Dan Herbert / @pocketninja_au

04/04/2012 at 05:21AM

37
#522 - jDeveloper / @jDevEE

04/19/2012 at 12:21AM

37
#523 - Christian Gaida / @chgaida

05/06/2012 at 09:12PM

37
#524 - Tom Sisk / @TomSisk

06/24/2012 at 01:15PM

37
#525 - Brent Goldman / @bgold

07/31/2012 at 05:29PM

37
#526 - Reed Riley / @ReedRile

08/14/2012 at 12:51AM

37
#527 - deigen / @deigen0

08/28/2012 at 09:44AM

37
#528 - Roman Makarenko / @rmakarenko

09/30/2012 at 02:12PM

37
#529 - EwHejucAkyec / @EwHejucAkyec

10/02/2012 at 06:56AM

37
#530 - Serge Pirotte / @SergePirotte

10/18/2012 at 05:04PM

37
#531 - Lieven Keersmaekers / @LievenKeersmaek

11/12/2012 at 08:06PM

37
#532 - Ray Lehtiniemi / @rayll

12/09/2012 at 11:28AM

37
#533 - a24f0600 / @a24f0600

12/13/2012 at 04:53PM

37
#534 - Gonzalo Arreche / @grilix

03/04/2013 at 07:14PM

37
#535 - Michael Kummer / @randompast

07/06/2013 at 07:03PM

37
#536 - Kevin McGladdery / @run_kmc

07/31/2013 at 05:24AM

37
#537 - Peter Johannson / @PeterJohannson

08/03/2013 at 08:07PM

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

08/23/2013 at 12:03PM

37
#539 - Throw Away / @throwaway111111

10/02/2013 at 12:04AM

37
#540 - Paul Roberts / @psxpau1

10/13/2013 at 07:29AM