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):
38
#601 - Eivind Jahren / @HaskellElephant

02/22/2011 at 08:39PM

38
#602 - Avinash Baliga / @avinashbaliga

03/24/2011 at 06:30AM

38
#603 - mightyfoo / @mightyfoo

05/25/2011 at 10:27AM

38
#604 - dtennant / @dtennant

06/01/2011 at 06:29PM

38
#605 - drooooooooooo / @droooooooooooo

08/01/2011 at 03:43AM

38
#606 - Sergey Kim / @skim1776

08/21/2011 at 07:21PM

38
#607 - jasper110 / @jasper110

09/21/2011 at 04:05PM

38
#608 - Martin Janiczek / @janiczek

10/14/2011 at 06:49PM

38
#609 - changling / @Lspacewalker

12/15/2011 at 09:06PM

38
#610 - sutringonavira / @sutringonavira

01/13/2012 at 08:57PM

38
#611 - Hannu Kröger / @hkroger

01/18/2012 at 10:33PM

38
#612 - Marcin Górnik / @gornikm

01/30/2012 at 08:25PM

38
#613 - Tim Uruski / @timuruski

02/08/2012 at 04:42AM

38
#614 - Michał Wróbel / @sparrovv_

03/12/2012 at 09:04PM

38
#615 - David Xia / @davidxia_

03/24/2012 at 12:38AM

38
#616 - bray / @bray

05/23/2012 at 02:54AM

38
#617 - Daniel Lundin / @danielundin

06/11/2012 at 02:59PM

38
#618 - Enrique Paredes / @iknite

08/18/2012 at 03:07PM

38
#619 - Greg McClure / @blackvoodoo

01/12/2013 at 08:29PM

38
#620 - Mikko Haavisto / @mhaavisto

02/28/2013 at 07:21PM

38
#621 - Sebastian Heil / @sebokopter

03/16/2013 at 03:31AM

38
#622 - smeier / @smeier

05/28/2013 at 07:28PM

38
#623 - James / @Dronak

08/29/2013 at 09:15PM

38
#624 - Joey Twiddle / @joeytwiddle

09/01/2013 at 01:53AM

38
#625 - hiroaki yasutomo / @kaminaly

09/06/2013 at 01:53AM

38
#626 - Rafa Garcia / @fafa

09/17/2013 at 08:53AM

38
#627 - Chris Ford / @ctford

10/20/2013 at 09:31AM

38
#628 - Matthew Kirk / @mjkirk

12/18/2013 at 05:19PM

38
#629 - Tom Richards / @the_tomrichards

12/20/2013 at 08:09PM

38
#630 - pikaren / @REALpikaren

12/21/2013 at 08:22AM