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

1757 active golfers, 7161 entries

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

05/09/2024 at 01:47PM

36
#>488 - Paul Molloy / @paulsmolloy

05/09/2024 at 09:32AM

36
#>488 - Paul Molloy / @paulsmolloy

05/09/2024 at 01:01PM

37
#>587 - Paul Molloy / @paulsmolloy

05/08/2024 at 07:34AM

43
#>1072 - Paul Molloy / @paulsmolloy

05/08/2024 at 06:07AM

44
#>1141 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:53AM

45
#>1185 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:50AM

47
#>1303 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:46AM

47
#>1303 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:48AM

48
#>1348 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:45AM

49
#>1381 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:44AM

50
#>1409 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:09PM

56
#>1545 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:42AM

57
#>1564 - Paul Molloy / @paulsmolloy

05/05/2024 at 04:43PM

58
#>1573 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:05PM

58
#>1574 - Paul Molloy / @paulsmolloy

05/07/2024 at 07:46AM

69
#>1661 - Paul Molloy / @paulsmolloy

10/09/2023 at 09:02PM

112
#>1738 - Paul Molloy / @paulsmolloy

10/09/2023 at 08:59PM