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

1369 active golfers, 5569 entries

Leaderboard (lowest score wins):
33
#241 - John Smith / @literacyisgood

02/02/2016 at 10:45PM

33
#242 - ben kavanagh / @bkava

02/22/2016 at 04:11AM

33
#243 - Robber Toe / @robbertoe

04/03/2016 at 02:22AM

33
#244 - Vaughn Cato / @vaughncato

04/23/2016 at 02:33PM

33
#245 - John Goes / @johnwgoes

05/04/2016 at 03:21PM

33
#246 - vic © / @2r2w

05/23/2016 at 03:20PM

33
#247 - Gabriel Tailor / @gabriel_tailor

06/21/2016 at 03:41AM

33
#248 - Ram Tamtam / @ramtamtamtam

06/22/2016 at 02:08PM

33
#249 - Alexander Bessonov / @nonsleepr

03/13/2017 at 10:31PM

33
#250 - Solomon / @Trugbildjaeger

03/30/2017 at 08:13PM

33
#251 - Remus Dalrymple / @bornintheflames

05/06/2017 at 10:23AM

33
#252 - Дима / @dimkino

09/07/2017 at 06:33PM

34
#253 - Ricardo Mendes / @locks

12/30/2010 at 03:45PM

34
#254 - Richard Sanchez / @vimlearner

01/01/2011 at 05:26AM

34
#255 - Jonathan / @jdelStrother

01/02/2011 at 07:16PM

34
#256 - derp derp / @derp__

01/05/2011 at 06:55AM

34
#257 - Balkoth / @_Balkoth_

01/08/2011 at 04:41PM

34
#258 - Ben Griffiths / @beng

01/11/2011 at 04:49PM

34
#259 - Andrey Ivanov / @Bytamine

01/19/2011 at 09:20PM

34
#260 - Oleg Roshupkin / @jjjahson

01/20/2011 at 04:01PM

34
#261 - Andrey A. Ugolnik / @andreyugolnik

01/22/2011 at 02:30AM

34
#262 - BigBlackBear / @BigBlackBear

01/26/2011 at 08:57PM

34
#263 - Rainer Testa / @Rainersglueck

02/15/2011 at 10:19PM

34
#264 - Sam Washington / @shabalay

08/18/2011 at 03:59PM

34
#265 - abelourenco / @abelourenco

12/06/2011 at 08:43PM

34
#266 - A / @tndrnt

12/10/2011 at 11:10AM

34
#267 - Mikael Amborn / @mikaelamborn

01/30/2012 at 08:48PM

34
#268 - Dave Harrington / @ozzy_dave

02/17/2012 at 11:14PM

34
#269 - Nicholas Amina / @apolatg

09/25/2012 at 06:28PM

34
#270 - Pavel Ryumin / @alcworx

09/29/2012 at 02:33PM