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

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

1751 active golfers, 7134 entries

Solutions by @Mcthecuber:
49
#1381 - Justin Choi / @Mcthecuber

07/01/2024 at 06:26PM

59
#>1584 - Justin Choi / @Mcthecuber

07/01/2024 at 06:19PM

62
#>1614 - Justin Choi / @Mcthecuber

07/01/2024 at 06:25PM

67
#>1642 - Justin Choi / @Mcthecuber

07/01/2024 at 06:18PM

75
#>1682 - Justin Choi / @Mcthecuber

07/01/2024 at 06:17PM