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

1405 active golfers, 5714 entries

Leaderboard (lowest score wins):
41
#781 - Nik Klassen / @nik_klassen

10/17/2013 at 08:16PM

41
#782 - Nathan Wallace / @nathanmwallace

11/05/2013 at 03:26PM

41
#783 - Mathieu Larouche / @matdube

11/18/2013 at 05:03PM

41
#784 - Anatoliy C. / @1602

12/19/2013 at 03:44PM

41
#785 - Joshua Appelman / @JoshuaAppelman

12/20/2013 at 09:10PM

41
#786 - Alessandro Lisander / @wuiimu

01/04/2014 at 04:26PM

41
#787 - albert peng / @holoiii

01/10/2014 at 01:26AM

41
#788 - Omer Lachish / @rauchy

01/28/2014 at 01:51PM

41
#789 - Bill Booth / @ohiopyle

01/29/2014 at 08:52AM

41
#790 - Brian Olpin / @bolpin

03/22/2014 at 10:40PM

41
#791 - TapTemplate / @TapTemplate

06/29/2014 at 04:04AM

41
#792 - liz monfett / @lizmonfett

07/05/2014 at 04:16AM

41
#793 - David Hume / @djh95

07/07/2014 at 10:30AM

41
#794 - id / @tunguska112

07/27/2014 at 09:37AM

41
#795 - JW / @justuswilhelm

01/06/2015 at 09:30PM

41
#796 - The Kiba / @thekiba88

02/22/2015 at 02:48PM

41
#797 - 親の金でシャンプーを買うな / @jajkeqos

04/08/2015 at 04:04PM

41
#798 - chvzvhn / @chvzvhn

04/26/2015 at 06:33AM

41
#799 - Grisha Pushkov / @readoonly

05/14/2015 at 08:31AM

41
#800 - Daxin / @Daxin2010

09/28/2015 at 02:01PM

41
#801 - Pete Sevander / @Sevanteri

11/11/2015 at 10:56AM

41
#802 - Jakob Schöttl / @jschoettl

12/21/2015 at 02:46AM

41
#803 - Sebastian Pfluegelm / @sebastian_pflgl

06/22/2016 at 07:44PM

41
#804 - Peter Gundel / @GundelMail

05/15/2017 at 11:42AM

41
#805 - Ron Alexssen / @Ralexhere

10/30/2017 at 06:31AM

41
#806 - Evgeny`s Kindle / @EvgenyKindle

04/24/2018 at 10:06AM

41
#807 - Rakesh P / @rakeshpgopal

05/23/2018 at 06:03PM

41
#808 - Kris Ezra / @kris_ezra

09/12/2018 at 03:39AM

41
#809 - Dryvnt / @Dryvnt

04/04/2019 at 01:20PM

41
#810 - Simon Zeng / @KronicMan

06/15/2019 at 05:01PM