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):
36
#421 - icdark / @icdark

05/29/2011 at 09:41PM

36
#422 - Eric Stewart / @ericstewart

05/30/2011 at 05:26AM

36
#423 - wusher / @wusher

05/30/2011 at 09:47PM

36
#424 - Andre Luiz / @alpardal

05/31/2011 at 12:39AM

36
#425 - Robert McBride / @MrException

06/15/2011 at 11:44PM

36
#426 - Jim Infield / @jinfield

07/14/2011 at 03:46AM

36
#427 - Jason Then / @racc69

08/08/2011 at 01:28AM

36
#428 - Ben Sherman / @bensherman

09/24/2011 at 12:11AM

36
#429 - Derrick Spell / @dcsesq

09/28/2011 at 04:18AM

36
#430 - p0ckets / @p0ckets

10/07/2011 at 01:02AM

36
#431 - Matt Woelk / @MattWoelk

11/11/2011 at 08:30PM

36
#432 - Maciej Suchecki / @mcSuchecki

11/20/2011 at 11:33PM

36
#433 - 0x5042 / @0x5042

11/27/2011 at 08:20PM

36
#434 - browsi / @browsi

03/08/2012 at 03:44PM

36
#435 - Aaron Mueller / @fu86

05/20/2012 at 03:50PM

36
#436 - mwatkward / @AftrschoolSpe

06/22/2012 at 09:42AM

36
#437 - ☈king / @SharpsawDotOrg

06/25/2012 at 04:48AM

36
#438 - Aaron Hall / @aarontothemax

08/27/2012 at 01:35AM

36
#439 - Mikko Loponen / @lopossumi

11/02/2012 at 02:32PM

36
#440 - Echosa / @echosa

12/13/2012 at 11:59PM

36
#441 - Xinruo Sun / @xiaoruoruo

12/23/2012 at 12:43PM

36
#442 - Ben / @ben_g_thomas

01/09/2013 at 09:48PM

36
#443 - Claes Mogren / @claesmogren

03/19/2013 at 06:47AM

36
#444 - gnobbles / @gnobbles

03/30/2013 at 08:56PM

36
#445 - Tyler / @tylerbindon

03/31/2013 at 01:44AM

36
#446 - jeepee / @jeepee_test

06/10/2013 at 12:28PM

36
#447 - powertomato / @powertomato

06/27/2013 at 10:41PM

36
#448 - zmf_tim / @zmf_tim

07/04/2013 at 08:58PM

36
#449 - brett / @brettyukich

09/18/2013 at 09:33PM

36
#450 - Rafael Rendon Pablo / @__rendon__

12/15/2013 at 03:01AM