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 1344 remaining solutions by signing in and submitting your own entry
#1345 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

1345 active golfers, 5482 entries

Leaderboard (lowest score wins):
80
#1321 - Nanne / @Whazor

12/28/2010 at 10:19PM

81
#1322 - Rap Game Dan Aykroyd / @rapdanaykroyd

02/02/2012 at 06:44PM

82
#1323 - Ed Gibbs / @edward_gibbs

08/01/2011 at 02:23PM

82
#1324 - Ayman Farhat / @aymanfarhat

06/03/2015 at 12:05PM

85
#1325 - Peter Esselius / @esselius

02/19/2013 at 04:20PM

85
#1326 - Huj8228 / @Huj82281

05/06/2013 at 05:15PM

86
#1327 - Alex Budilovsky / @alexbudy

05/04/2018 at 05:47PM

87
#1328 - Blake / @greyblake

12/31/2010 at 01:45AM

88
#1329 - Andy Waite / @andyw8

11/19/2013 at 01:44PM

90
#1330 - geier / @geier

01/30/2012 at 01:04PM

93
#1331 - george redinger / @gredinger

06/15/2011 at 01:55AM

96
#1332 - Matthias Kausl / @sig_segv

04/23/2019 at 06:52PM

98
#1333 - Andrew Nordman / @Cadwallion

05/28/2011 at 04:05AM

99
#1334 - Bèr Kessels / @berkes

01/05/2011 at 05:04PM

103
#1335 - Alexey Kovyrin / @kovyrin

12/29/2010 at 01:57PM

107
#1336 - Vadim Golub / @vdmgolub

01/19/2011 at 08:54AM

110
#1337 - Aaron LaRoche / @alaroche22

06/03/2011 at 01:30PM

123
#1338 - Nick Jones / @nickj89

12/29/2010 at 12:15PM

125
#1339 - Terr / @TerrRandom

06/04/2013 at 12:23PM

132
#1340 - Valeriy Viktorovskiy / @viktorovskiy

12/28/2010 at 11:35PM

137
#1341 - Dan Reiland / @dmreiland

12/29/2010 at 09:59PM

139
#1342 - Aadi Deshpande / @cilquirm

12/29/2010 at 05:20PM

161
#1343 - Akeem Adeniji / @akeem

12/28/2010 at 11:44PM

166
#1344 - Jeremy Woertink / @jeremywoertink

12/28/2010 at 09:20PM

206
#1345 - Patrick Muldoon / @d00n

12/29/2010 at 03:12PM