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

1312 active golfers, 5363 entries

Leaderboard (lowest score wins):
33
#181 - Emeric Dupont / @stucule

08/22/2011 at 12:50PM

33
#182 - Nathan Womack / @nwomack

08/22/2011 at 04:16PM

33
#183 - Katrina Owen / @kytrinyx

08/25/2011 at 04:29PM

33
#184 - Daniel Stoza / @dstoza

08/25/2011 at 06:16PM

33
#185 - zephod / @zephod

09/28/2011 at 10:12PM

33
#186 - murky-satyr / @m_satyr

10/16/2011 at 03:54PM

33
#187 - Sergey Panin / @dixPro

11/08/2011 at 09:59AM

33
#188 - Gordon DuQuesnay / @gduquesnay

11/23/2011 at 05:57PM

33
#189 - You-Siang Lin / @yslinnctu

11/24/2011 at 03:48AM

33
#190 - Kevin / @exclipy

12/01/2011 at 10:54AM

33
#191 - palentine / @palentine

12/12/2011 at 07:07PM

33
#192 - Ali Moeeny / @alimoeeny

12/13/2011 at 12:05PM

33
#193 - Jeff Siegel / @jdsiegel

12/24/2011 at 09:33AM

33
#194 - John Anderson / @opejn

12/29/2011 at 08:20AM

33
#195 - Calvin Condon / @ccondon

01/30/2012 at 03:40AM

33
#196 - maxthoursie / @maxthoursie

01/30/2012 at 08:35PM

33
#197 - Henry Johnes / @xeosvn

01/31/2012 at 12:03PM

33
#198 - scottley / @scottley

02/07/2012 at 10:20AM

33
#199 - Boyance / @Boyance_nl

05/03/2012 at 06:32PM

33
#200 - Urtica dioica / @udioica

05/27/2012 at 04:02PM

33
#201 - Chris Brown / @engineercyb

07/13/2012 at 01:07AM

33
#202 - Jesse Weaver / @jessepweaver

08/16/2012 at 01:55AM

33
#203 - usrbin / @notusrbin

08/16/2012 at 01:59AM

33
#204 - Nolic / @cNolic

10/14/2012 at 08:39PM

33
#205 - Darcy Parker / @DarcyParker

10/15/2012 at 09:37PM

33
#206 - Jimmy Mabey / @mabeyj

11/24/2012 at 04:37AM

33
#207 - Alec Goebel / @zego5360

01/07/2013 at 12:03AM

33
#208 - Yann Moisan / @YannMoisan

02/01/2013 at 03:24PM

33
#209 - Trevor Powell / @DoomedBunnies

03/20/2013 at 07:04AM

33
#210 - Marco Hinz / @_mhinz_

04/19/2013 at 06:17AM