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

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

1482 active golfers, 6015 entries

Solutions by @SeanHwangt:
32
#169 - Sean Hwang / @SeanHwangt

02/02/2022 at 01:00AM

34
#>304 - Sean Hwang / @SeanHwangt

02/02/2022 at 01:00AM

37
#>535 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:46AM

40
#>776 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:43AM

42
#>915 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:41AM

44
#>1022 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:41AM

58
#>1375 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:40AM

78
#>1452 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:38AM

95
#>1468 - Sean Hwang / @SeanHwangt

02/02/2022 at 12:37AM