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

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

1699 active golfers, 6937 entries

Solutions by @andreas_nasman:
32
#172 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:41AM

32
#>172 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:55AM

32
#>172 - Andreas Näsman / @andreas_nasman

06/19/2022 at 10:17AM

32
#>172 - Andreas Näsman / @andreas_nasman

06/19/2022 at 02:54PM

33
#>268 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:38AM

34
#>313 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:18AM

35
#>392 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:17AM

36
#>477 - Andreas Näsman / @andreas_nasman

06/17/2022 at 09:49AM

36
#>477 - Andreas Näsman / @andreas_nasman

06/17/2022 at 10:16AM

38
#>662 - Andreas Näsman / @andreas_nasman

06/17/2022 at 09:45AM

39
#>764 - Andreas Näsman / @andreas_nasman

06/17/2022 at 09:44AM

40
#>837 - Andreas Näsman / @andreas_nasman

06/17/2022 at 09:41AM

41
#>921 - Andreas Näsman / @andreas_nasman

06/17/2022 at 09:35AM

43
#>1053 - Andreas Näsman / @andreas_nasman

06/17/2022 at 08:09AM