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

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

1686 active golfers, 6884 entries

Solutions by @paulsmolloy:
35
#397 - Paul Molloy / @paulsmolloy

05/09/2024 at 01:47PM

36
#>482 - Paul Molloy / @paulsmolloy

05/09/2024 at 09:32AM

36
#>482 - Paul Molloy / @paulsmolloy

05/09/2024 at 01:01PM

37
#>579 - Paul Molloy / @paulsmolloy

05/08/2024 at 07:34AM

43
#>1051 - Paul Molloy / @paulsmolloy

05/08/2024 at 06:07AM

44
#>1119 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:53AM

45
#>1162 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:50AM

47
#>1278 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:46AM

47
#>1278 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:48AM

48
#>1323 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:45AM

49
#>1356 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:44AM

50
#>1383 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:09PM

56
#>1504 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:42AM

57
#>1522 - Paul Molloy / @paulsmolloy

05/05/2024 at 04:43PM

58
#>1530 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:05PM

58
#>1531 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:46AM

69
#>1601 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:02PM

112
#>1673 - Paul Molloy / @paulsmolloy

10/09/2023 at 08:59PM