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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
41
#751 - Jason Bruce / @jbrucenet

09/07/2012 at 10:52PM

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

10/26/2012 at 02:31PM

41
#753 - Nissan Pow / @k4mizu

10/28/2012 at 12:51AM

41
#754 - Underhill Labs / @underhilllabs

10/29/2012 at 08:36PM

41
#755 - Chris LeBlanc / @cleblanc87

11/03/2012 at 02:24AM

41
#756 - Joshua Travis / @jktravis

11/11/2012 at 02:24AM

41
#757 - Eric Andres / @eric_m_andres

12/06/2012 at 05:00AM

41
#758 - Arun / @UArunKumar

12/08/2012 at 03:48AM

41
#759 - yohe / @yohe_0616

12/23/2012 at 07:41AM

41
#760 - Josh Johnson / @jnjosh

04/01/2013 at 07:52PM

41
#761 - David Hoeffer / @dhoeffer

04/24/2013 at 02:24PM

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

07/12/2013 at 02:23AM

41
#763 - Sencer Selcuk / @sencers_

10/10/2013 at 07:20PM

41
#764 - Joakim / @golfjoakim

10/12/2013 at 08:13AM

41
#765 - Nik Klassen / @nik_klassen

10/17/2013 at 08:16PM

41
#766 - Nathan Wallace / @nathanmwallace

11/05/2013 at 03:26PM

41
#767 - Mathieu Larouche / @matdube

11/18/2013 at 05:03PM

41
#768 - Anatoliy C. / @1602

12/19/2013 at 03:44PM

41
#769 - Joshua Appelman / @JoshuaAppelman

12/20/2013 at 09:10PM

41
#770 - Alessandro Lisander / @wuiimu

01/04/2014 at 04:26PM

41
#771 - albert peng / @holoiii

01/10/2014 at 01:26AM

41
#772 - Omer Lachish / @rauchy

01/28/2014 at 01:51PM

41
#773 - Bill Booth / @ohiopyle

01/29/2014 at 08:52AM

41
#774 - Brian Olpin / @bolpin

03/22/2014 at 10:40PM

41
#775 - TapTemplate / @TapTemplate

06/29/2014 at 04:04AM

41
#776 - liz monfett / @lizmonfett

07/05/2014 at 04:16AM

41
#777 - David Hume / @djh95

07/07/2014 at 10:30AM

41
#778 - id / @tunguska112

07/27/2014 at 09:37AM

41
#779 - JW / @justuswilhelm

01/06/2015 at 09:30PM

41
#780 - The Kiba / @thekiba88

02/22/2015 at 02:48PM