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

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

1706 active golfers, 6982 entries

Solutions by @shahanavazm:
36
#482 - shahanavaz m / @shahanavazm

01/31/2024 at 09:35PM

39
#>765 - shahanavaz m / @shahanavazm

04/02/2022 at 02:50AM

40
#>840 - shahanavaz m / @shahanavazm

04/01/2022 at 12:44AM

41
#>924 - shahanavaz m / @shahanavazm

02/12/2022 at 04:15AM

41
#>924 - shahanavaz m / @shahanavazm

02/19/2022 at 01:02AM

41
#>930 - shahanavaz m / @shahanavazm

01/17/2024 at 07:02PM

42
#>1003 - shahanavaz m / @shahanavazm

01/16/2024 at 08:28PM

42
#>1003 - shahanavaz m / @shahanavazm

01/16/2024 at 08:29PM

42
#>1003 - shahanavaz m / @shahanavazm

01/16/2024 at 08:30PM

43
#>1057 - shahanavaz m / @shahanavazm

02/12/2022 at 04:13AM

43
#>1057 - shahanavaz m / @shahanavazm

03/31/2022 at 04:15AM

43
#>1057 - shahanavaz m / @shahanavazm

03/31/2022 at 09:47PM

43
#>1059 - shahanavaz m / @shahanavazm

01/16/2024 at 08:26PM

44
#>1129 - shahanavaz m / @shahanavazm

01/16/2024 at 08:22PM

45
#>1167 - shahanavaz m / @shahanavazm

02/12/2022 at 04:05AM

45
#>1168 - shahanavaz m / @shahanavazm

02/26/2023 at 12:53AM

48
#>1332 - shahanavaz m / @shahanavazm

01/16/2024 at 08:21PM

51
#>1416 - shahanavaz m / @shahanavazm

02/12/2022 at 03:56AM

55
#>1501 - shahanavaz m / @shahanavazm

02/12/2022 at 03:40AM

55
#>1502 - shahanavaz m / @shahanavazm

02/26/2023 at 12:51AM

191
#>1705 - shahanavaz m / @shahanavazm

01/16/2024 at 08:20PM