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):
33
#181 - Sergey Doroshenko / @dorserg

03/04/2011 at 07:48AM

33
#182 - Ruy Diaz / @diazruy

03/08/2011 at 06:20PM

33
#183 - Paweu1kZ nbNeyIhH / @yUQlwsFpRSzxJFh

03/09/2011 at 07:22AM

33
#184 - Aaron Jensen / @aaronjensen

03/18/2011 at 06:00AM

33
#185 - Mikael Gustavsson / @slvmnd

04/19/2011 at 02:53PM

33
#186 - こばばー / @symmet

04/24/2011 at 09:05AM

33
#187 - kjrn / @kjrnleto

05/20/2011 at 07:27PM

33
#188 - Emile Swarts / @EmileSwarts

05/29/2011 at 11:38AM

33
#189 - Justin Love / @wondible

06/03/2011 at 12:18PM

33
#190 - Black Wolf / @LoboVimGolf

06/15/2011 at 09:24AM

33
#191 - Rolf Bjaanes / @rolfb

06/15/2011 at 06:58PM

33
#192 - Jonathan / @saysjonathan

07/01/2011 at 01:21AM

33
#193 - Junfeng / @junfeng

07/13/2011 at 11:52AM

33
#194 - Carlo Biedenharn / @Carlohedron

07/15/2011 at 09:46PM

33
#195 - ineb / @ineb0

08/14/2011 at 02:57PM

33
#196 - Emeric Dupont / @stucule

08/22/2011 at 12:50PM

33
#197 - Nathan Womack / @nwomack

08/22/2011 at 04:16PM

33
#198 - Katrina Owen / @kytrinyx

08/25/2011 at 04:29PM

33
#199 - Daniel Stoza / @dstoza

08/25/2011 at 06:16PM

33
#200 - zephod / @zephod

09/28/2011 at 10:12PM

33
#201 - murky-satyr / @m_satyr

10/16/2011 at 03:54PM

33
#202 - Sergey Panin / @dixPro

11/08/2011 at 09:59AM

33
#203 - Gordon DuQuesnay / @gduquesnay

11/23/2011 at 05:57PM

33
#204 - You-Siang Lin / @yslinnctu

11/24/2011 at 03:48AM

33
#205 - Kevin / @exclipy

12/01/2011 at 10:54AM

33
#206 - palentine / @palentine

12/12/2011 at 07:07PM

33
#207 - Ali Moeeny MD PhD / @alimoeeny

12/13/2011 at 12:05PM

33
#208 - Jeff Siegel / @jdsiegel

12/24/2011 at 09:33AM

33
#209 - John Anderson / @opejn

12/29/2011 at 08:20AM

33
#210 - Calvin Condon / @ccondon

01/30/2012 at 03:40AM