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

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

1708 active golfers, 6984 entries

Solutions by @petemud:
32
#176 - Petro Mudrievskyj / @petemud

06/27/2024 at 09:09AM

34
#>322 - Petro Mudrievskyj / @petemud

06/27/2024 at 08:24AM

36
#>484 - Petro Mudrievskyj / @petemud

06/27/2024 at 08:16AM

37
#>583 - Petro Mudrievskyj / @petemud

06/27/2024 at 08:14AM

39
#>773 - Petro Mudrievskyj / @petemud

06/27/2024 at 08:12AM

40
#>848 - Petro Mudrievskyj / @petemud

06/27/2024 at 08:06AM

43
#>1062 - Petro Mudrievskyj / @petemud

06/27/2024 at 07:57AM

46
#>1227 - Petro Mudrievskyj / @petemud

06/27/2024 at 07:42AM

58
#>1549 - Petro Mudrievskyj / @petemud

06/27/2024 at 07:20AM