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 by @igrigorik:

Unlock 15 remaining solutions by signing in and submitting your own entry
Created by: @igrigorik

1706 active golfers, 6982 entries

Solutions by @igrigorik:
68
#1614 - Ilya Grigorik / @igrigorik

12/31/2010 at 08:07PM

76
#>1647 - Ilya Grigorik / @igrigorik

01/06/2011 at 05:16AM

78
#>1654 - Ilya Grigorik / @igrigorik

03/17/2012 at 07:12PM

83
#>1664 - Ilya Grigorik / @igrigorik

09/19/2012 at 05:52AM

85
#>1665 - Ilya Grigorik / @igrigorik

05/08/2011 at 06:25PM

97
#>1684 - Ilya Grigorik / @igrigorik

10/11/2014 at 05:10PM

106
#>1690 - Ilya Grigorik / @igrigorik

03/17/2011 at 07:45PM

129
#>1697 - Ilya Grigorik / @igrigorik

12/11/2011 at 05:56PM

131
#>1697 - Ilya Grigorik / @igrigorik

01/11/2013 at 06:30AM

161
#>1703 - Ilya Grigorik / @igrigorik

12/29/2010 at 04:28AM

166
#>1704 - Ilya Grigorik / @igrigorik

12/28/2010 at 06:55PM

172
#>1705 - Ilya Grigorik / @igrigorik

12/28/2010 at 10:24PM

174
#>1705 - Ilya Grigorik / @igrigorik

12/30/2010 at 05:08AM

259
#>1706 - Ilya Grigorik / @igrigorik

12/28/2010 at 06:59PM

281
#>1706 - Ilya Grigorik / @igrigorik

12/28/2010 at 10:25PM