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

1790 active golfers, 7252 entries

Leaderboard (lowest score wins):
36
#421 - Derrick Camerino / @robustdj

04/21/2011 at 02:10AM

36
#422 - Terje Larsen / @terlars

05/09/2011 at 01:16PM

36
#423 - Charles Max Wood / @cmaxw

05/24/2011 at 10:27PM

36
#424 - icdark / @icdark

05/29/2011 at 09:41PM

36
#425 - Eric Stewart / @ericstewart

05/30/2011 at 05:26AM

36
#426 - wusher / @wusher

05/30/2011 at 09:47PM

36
#427 - Andre Luiz / @alpardal

05/31/2011 at 12:39AM

36
#428 - Robert McBride / @MrException

06/15/2011 at 11:44PM

36
#429 - Jim Infield / @jinfield

07/14/2011 at 03:46AM

36
#430 - Jason Then / @racc69

08/08/2011 at 01:28AM

36
#431 - Ben Sherman / @bensherman

09/24/2011 at 12:11AM

36
#432 - Derrick Spell / @dcsesq

09/28/2011 at 04:18AM

36
#433 - p0ckets / @p0ckets

10/07/2011 at 01:02AM

36
#434 - Matt Woelk / @MattWoelk

11/11/2011 at 08:30PM

36
#435 - Maciej Suchecki / @mcSuchecki

11/20/2011 at 11:33PM

36
#436 - 0x5042 / @0x5042

11/27/2011 at 08:20PM

36
#437 - browsi / @browsi

03/08/2012 at 03:44PM

36
#438 - Aaron Mueller / @fu86

05/20/2012 at 03:50PM

36
#439 - mwatkward / @AftrschoolSpe

06/22/2012 at 09:42AM

36
#440 - ☈king / @SharpsawDotOrg

06/25/2012 at 04:48AM

36
#441 - Aaron Hall / @aarontothemax

08/27/2012 at 01:35AM

36
#442 - Mikko Loponen / @lopossumi

11/02/2012 at 02:32PM

36
#443 - Echosa / @echosa

12/13/2012 at 11:59PM

36
#444 - Xinruo Sun / @xiaoruoruo

12/23/2012 at 12:43PM

36
#445 - Ben / @ben_g_thomas

01/09/2013 at 09:48PM

36
#446 - Claes Mogren / @claesmogren

03/19/2013 at 06:47AM

36
#447 - gnobbles / @gnobbles

03/30/2013 at 08:56PM

36
#448 - Tyler / @tylerbindon

03/31/2013 at 01:44AM

36
#449 - jeepee / @jeepee_test

06/10/2013 at 12:28PM

36
#450 - powertomato / @powertomato

06/27/2013 at 10:41PM