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

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

1708 active golfers, 6984 entries

Solutions by @tianxiaweiyidao:
34
#320 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 04:27PM

35
#>396 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 04:19PM

37
#>581 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 03:56PM

41
#>930 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 03:52PM

42
#>1004 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 03:48PM

46
#>1227 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 03:37PM

54
#>1488 - tianxiaweiyidao / @tianxiaweiyidao

04/17/2024 at 03:23PM