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

The best way to learn is to practice. Below, you will find some of the solutions other golfers have entered. To unlock higher ranked solutions, submit your own entry which does as well or better than the solutions you can currently see - climb the ladder!

Check out these helpful resources to improve your Vim skills... Game on.

Unlock 1364 remaining solutions by signing in and submitting your own entry
#1365 Patrick Muldoon / @d00n - Score: 206 - 12/29/10 @ 15:12
<Esc>:<Up><Up><Up><Up><Up>g.<BS>/.*def.$<BS>*end.*/d<CR>:v/\S/f<BS>d<CR>fai*<Esc><Right><Right>cf))<Esc><Down><Left>i.join(',')<Esc>lldf:df"a"<Esc>=<Esc><Esc><BS><Up><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>xxxxxi  <Down><Down><Esc>x<Up><Right>xx<Esc>:wq<CR>

0 comments


Created by: @igrigorik

1365 active golfers, 5551 entries

Leaderboard (lowest score wins):
93
#1351 - george redinger / @gredinger

06/15/2011 at 01:55AM

96
#1352 - Matthias Kausl / @sig_segv

04/23/2019 at 06:52PM

98
#1353 - Andrew Nordman / @Cadwallion

05/28/2011 at 04:05AM

99
#1354 - Bèr Kessels / @berkes

01/05/2011 at 05:04PM

103
#1355 - Alexey Kovyrin / @kovyrin

12/29/2010 at 01:57PM

107
#1356 - Vadim Golub / @vdmgolub

01/19/2011 at 08:54AM

110
#1357 - Aaron LaRoche / @alaroche22

06/03/2011 at 01:30PM

123
#1358 - Nick Jones / @nickj89

12/29/2010 at 12:15PM

125
#1359 - Terr / @TerrRandom

06/04/2013 at 12:23PM

132
#1360 - Valeriy Viktorovskiy / @viktorovskiy

12/28/2010 at 11:35PM

137
#1361 - Dan Reiland / @dmreiland

12/29/2010 at 09:59PM

139
#1362 - Aadi Deshpande / @cilquirm

12/29/2010 at 05:20PM

161
#1363 - Akeem Adeniji / @akeem

12/28/2010 at 11:44PM

166
#1364 - Jeremy Woertink / @jeremywoertink

12/28/2010 at 09:20PM

206
#1365 - Patrick Muldoon / @d00n

12/29/2010 at 03:12PM