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 @matthews314:

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

1825 active golfers, 7415 entries

Solutions by @matthews314:
38
#691 - Matteo Smaila / @matthews314

01/02/2024 at 12:30AM

38
#>691 - Matteo Smaila / @matthews314

01/02/2024 at 12:40AM

40
#>879 - Matteo Smaila / @matthews314

01/02/2024 at 12:25AM

40
#>879 - Matteo Smaila / @matthews314

01/02/2024 at 12:29AM

41
#>964 - Matteo Smaila / @matthews314

01/02/2024 at 12:19AM

45
#>1213 - Matteo Smaila / @matthews314

01/02/2024 at 12:15AM

47
#>1333 - Matteo Smaila / @matthews314

01/02/2024 at 12:08AM

61
#>1662 - Matteo Smaila / @matthews314

01/02/2024 at 12:07AM

63
#>1681 - Matteo Smaila / @matthews314

01/02/2024 at 12:05AM

67
#>1707 - Matteo Smaila / @matthews314

01/02/2024 at 12:03AM

71
#>1735 - Matteo Smaila / @matthews314

01/01/2024 at 11:52PM

80
#>1765 - Matteo Smaila / @matthews314

01/01/2024 at 11:48PM

110
#>1802 - Matteo Smaila / @matthews314

01/01/2024 at 11:38PM

110
#>1802 - Matteo Smaila / @matthews314

01/01/2024 at 11:42PM

118
#>1806 - Matteo Smaila / @matthews314

01/01/2024 at 11:28PM