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

1321 active golfers, 5391 entries

Leaderboard (lowest score wins):
36
#361 - Behnam Esfahbod / @zwnj

12/31/2010 at 03:01PM

36
#362 - Matthew Draper / @_matthewd

01/06/2011 at 05:53AM

36
#363 - Tim Chase / @gumnos

01/08/2011 at 03:14PM

36
#364 - Pete Johns / @johnsyweb

01/14/2011 at 09:25PM

36
#365 - Anders Janmyr / @andersjanmyr

01/16/2011 at 03:06PM

36
#366 - Jed Hurt / @meekish

02/05/2011 at 05:44AM

36
#367 - Arthur Chiu / @arthur_chiu

02/06/2011 at 02:09AM

36
#368 - Pavlo Klets / @p01nt

02/06/2011 at 07:11PM

36
#369 - Derrick Camerino / @robustdj

04/21/2011 at 02:10AM

36
#370 - Terje Larsen / @terlars

05/09/2011 at 01:16PM

36
#371 - Charles Max Wood / @cmaxw

05/24/2011 at 10:27PM

36
#372 - icdark / @icdark

05/29/2011 at 09:41PM

36
#373 - Eric Stewart / @ericstewart

05/30/2011 at 05:26AM

36
#374 - wusher / @wusher

05/30/2011 at 09:47PM

36
#375 - Andre Luiz / @alpardal

05/31/2011 at 12:39AM

36
#376 - Robert McBride / @MrException

06/15/2011 at 11:44PM

36
#377 - Jim Infield / @jinfield

07/14/2011 at 03:46AM

36
#378 - Jason Then / @racc69

08/08/2011 at 01:28AM

36
#379 - Ben Sherman / @bensherman

09/24/2011 at 12:11AM

36
#380 - Derrick Spell / @dcsesq

09/28/2011 at 04:18AM

36
#381 - p0ckets / @p0ckets

10/07/2011 at 01:02AM

36
#382 - Matt Woelk / @MattWoelk

11/11/2011 at 08:30PM

36
#383 - Maciej Suchecki / @mcSuchecki

11/20/2011 at 11:33PM

36
#384 - 0x5042 / @0x5042

11/27/2011 at 08:20PM

36
#385 - browsi / @browsi

03/08/2012 at 03:44PM

36
#386 - Aaron Mueller / @fu86

05/20/2012 at 03:50PM

36
#387 - mwatkward / @AftrschoolSpe

06/22/2012 at 09:42AM

36
#388 - ☈king / @SharpsawDotOrg

06/25/2012 at 04:48AM

36
#389 - Aaron Hall / @aarontothemax

08/27/2012 at 01:35AM

36
#390 - Mikko Loponen / @lopossumi

11/02/2012 at 02:32PM