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
#211 - maxthoursie / @maxthoursie

01/30/2012 at 08:35PM

33
#212 - Henry Johnes / @xeosvn

01/31/2012 at 12:03PM

33
#213 - scottley / @scottley

02/07/2012 at 10:20AM

33
#214 - Boyance / @Boyance_nl

05/03/2012 at 06:32PM

33
#215 - Urtica dioica / @udioica

05/27/2012 at 04:02PM

33
#216 - Chris Brown / @engineercyb

07/13/2012 at 01:07AM

33
#217 - Jesse Weaver / @jessepweaver

08/16/2012 at 01:55AM

33
#218 - usrbin / @notusrbin

08/16/2012 at 01:59AM

33
#219 - Nolic / @cNolic

10/14/2012 at 08:39PM

33
#220 - Darcy Parker / @DarcyParker

10/15/2012 at 09:37PM

33
#221 - Jimmy Mabey / @mabeyj

11/24/2012 at 04:37AM

33
#222 - Alec Goebel / @zego5360

01/07/2013 at 12:03AM

33
#223 - Yann Moisan / @YannMoisan

02/01/2013 at 03:24PM

33
#224 - Trevor Powell / @DoomedBunnies

03/20/2013 at 07:04AM

33
#225 - Marco Hinz / @_mhinz_

04/19/2013 at 06:17AM

33
#226 - iantalks / @iantalks

05/12/2013 at 02:04PM

33
#227 - rcmdnk / @rcmdnk

06/11/2013 at 10:13AM

33
#228 - Steve Tjoa / @stevetjoa

07/09/2013 at 06:07PM

33
#229 - Volodymyr / @vkrest

07/09/2013 at 06:32PM

33
#230 - Dom Armstrong / @dom_cycleface

08/19/2013 at 09:41PM

33
#231 - Super Garbage / @SuperGarbage0

08/29/2013 at 05:00AM

33
#232 - Dary Merckens / @merckens

09/23/2013 at 08:04PM

33
#233 - Dimitar Dimitrov / @kurkale6ka

10/17/2013 at 04:45PM

33
#234 - Casey Dwyer / @caseydwyer

10/23/2013 at 06:12AM

33
#235 - thasso / @thasso23

10/27/2013 at 01:28PM

33
#236 - James Scriven / @JamesDScriven

11/03/2013 at 09:33PM

33
#237 - Stefan Leszkiewicz / @stefanlz

11/17/2013 at 12:15AM

33
#238 - Павел Игоревич / @VizierST

02/02/2014 at 05:00PM

33
#239 - Jonathan Ellington / @JEllington90

02/02/2014 at 09:35PM

33
#240 - Zach Bennett / @saquintes

02/11/2014 at 03:35AM