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):
40
#721 - niels aamloos / @AamloosNiels

05/28/2016 at 01:10PM

40
#722 - Ryan van Rensburg / @rdvr001

07/21/2016 at 09:35AM

40
#723 - 赤佐田奈葉 / @akasatanaha_

06/26/2018 at 02:58AM

40
#724 - Diane Cochran / @DianeOfTheMoon

12/22/2018 at 09:57PM

40
#725 - Grant / @grant_7788

04/28/2019 at 02:42PM

40
#726 - vimgolfer24271 / @vimgolfer24271

05/13/2019 at 08:22AM

40
#727 - Chester Yap / @Chest_ErYap

07/27/2019 at 01:44PM

40
#728 - Baine Wedlock / @BaineWedlock

09/21/2019 at 02:34PM

40
#729 - vimgolfer / @vimgolfer7

10/04/2019 at 12:25AM

41
#730 - Benoit D / @Anbcorp

12/29/2010 at 04:07PM

41
#731 - dcbaok / @dcbaok

12/30/2010 at 06:05PM

41
#732 - Cartney McLennon / @mepsi_pax

01/05/2011 at 09:49PM

41
#733 - Chuck Phillips / @chuckphillips

01/07/2011 at 01:54AM

41
#734 - Bradly Feeley / @bradly

01/11/2011 at 12:14AM

41
#735 - Jes / @vim_jes

01/15/2011 at 03:18PM

41
#736 - Misha (Mike) Granin / @Granin

01/19/2011 at 05:01PM

41
#737 - Nathan Farrington / @nfarring

01/28/2011 at 09:44PM

41
#738 - Solomon White / @rubysolo

02/08/2011 at 03:53PM

41
#739 - Ilya Strukov / @i1ey

05/01/2011 at 05:01PM

41
#740 - akhilravidas / @akhilravidas

07/31/2011 at 01:31PM

41
#741 - Tim Tsu / @vimgolfpunk

09/04/2011 at 12:12AM

41
#742 - nicolas bo / @thevegeta

11/08/2011 at 02:31PM

41
#743 - Rik Lomas / @riklomas

12/31/2011 at 11:11PM

41
#744 - Michael Wynholds / @mwynholds

01/18/2012 at 01:22AM

41
#745 - Ashley Feniello / @AshleyFen

01/29/2012 at 05:00AM

41
#746 - Jyun-Fan Tsai / @fakecolor

02/04/2012 at 01:18PM

41
#747 - Simon ✌ Gate / @simongate

02/24/2012 at 07:00AM

41
#748 - mnx / @mnxx

06/05/2012 at 09:33AM

41
#749 - Andrew D. Wong / @andrewdwong

07/16/2012 at 05:51PM

41
#750 - Alykhan Kanji / @alykhank

08/17/2012 at 05:18PM