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

1847 active golfers, 7508 entries

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

05/09/2024 at 01:47PM

36
#>503 - Paul Molloy / @paulsmolloy

05/09/2024 at 09:32AM

36
#>503 - Paul Molloy / @paulsmolloy

05/09/2024 at 01:01PM

37
#>604 - Paul Molloy / @paulsmolloy

05/08/2024 at 07:34AM

43
#>1109 - Paul Molloy / @paulsmolloy

05/08/2024 at 06:07AM

44
#>1181 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:53AM

45
#>1229 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:50AM

47
#>1352 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:46AM

47
#>1352 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:48AM

48
#>1400 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:45AM

49
#>1434 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:44AM

50
#>1462 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:09PM

56
#>1607 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:42AM

57
#>1630 - Paul Molloy / @paulsmolloy

05/05/2024 at 04:43PM

58
#>1642 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:05PM

58
#>1643 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:46AM

69
#>1740 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:02PM

112
#>1825 - Paul Molloy / @paulsmolloy

10/09/2023 at 08:59PM