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

1398 active golfers, 5692 entries

Leaderboard (lowest score wins):
41
#751 - Nathan Farrington / @nfarring

01/28/2011 at 09:44PM

41
#752 - Solomon White / @rubysolo

02/08/2011 at 03:53PM

41
#753 - Ilya Strukov / @i1ey

05/01/2011 at 05:01PM

41
#754 - akhilravidas / @akhilravidas

07/31/2011 at 01:31PM

41
#755 - Tim Tsu / @vimgolfpunk

09/04/2011 at 12:12AM

41
#756 - nicolas bo / @thevegeta

11/08/2011 at 02:31PM

41
#757 - Rik Lomas / @riklomas

12/31/2011 at 11:11PM

41
#758 - Michael Wynholds / @mwynholds

01/18/2012 at 01:22AM

41
#759 - Ashley Feniello / @AshleyFen

01/29/2012 at 05:00AM

41
#760 - Jyun-Fan Tsai / @fakecolor

02/04/2012 at 01:18PM

41
#761 - Simon ✌ Gate / @simongate

02/24/2012 at 07:00AM

41
#762 - mnx / @mnxx

06/05/2012 at 09:33AM

41
#763 - Andrew D. Wong / @andrewdwong

07/16/2012 at 05:51PM

41
#764 - Alykhan Kanji / @alykhank

08/17/2012 at 05:18PM

41
#765 - Jason Bruce / @jbrucenet

09/07/2012 at 10:52PM

41
#766 - /d͡ʒuˈzɛp.pe/ / @gcapizzi

10/26/2012 at 02:31PM

41
#767 - Nissan Pow / @k4mizu

10/28/2012 at 12:51AM

41
#768 - Underhill Labs / @underhilllabs

10/29/2012 at 08:36PM

41
#769 - Chris LeBlanc / @cleblanc87

11/03/2012 at 02:24AM

41
#770 - Joshua Travis / @jktravis

11/11/2012 at 02:24AM

41
#771 - Eric Andres / @eric_m_andres

12/06/2012 at 05:00AM

41
#772 - Arun / @UArunKumar

12/08/2012 at 03:48AM

41
#773 - yohe / @yohe_0616

12/23/2012 at 07:41AM

41
#774 - Josh Johnson / @jnjosh

04/01/2013 at 07:52PM

41
#775 - David Hoeffer / @dhoeffer

04/24/2013 at 02:24PM

41
#776 - Woojung Kim 김우중 / @_kimwz

07/12/2013 at 02:23AM

41
#777 - Sencer Selcuk / @sencers_

10/10/2013 at 07:20PM

41
#778 - Joakim / @golfjoakim

10/12/2013 at 08:13AM

41
#779 - Nik Klassen / @nik_klassen

10/17/2013 at 08:16PM

41
#780 - Nathan Wallace / @nathanmwallace

11/05/2013 at 03:26PM