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

1338 active golfers, 5464 entries

Leaderboard (lowest score wins):
37
#481 - Amir Kremer / @AmirKremer

01/28/2014 at 01:53PM

37
#482 - John Phelan / @jackphel

02/02/2014 at 07:30PM

37
#483 - Seán Kelleher / @eZanmoto

02/04/2014 at 05:19PM

37
#484 - rocpatel / @rocpatel

02/10/2014 at 02:53PM

37
#485 - Spencer McAlpine / @spencermcalpine

02/11/2014 at 03:05PM

37
#486 - Will / @VVi11_I_AM

02/16/2014 at 04:37AM

37
#487 - Robert Siemieniec / @rsiemieniec

02/18/2014 at 02:51PM

37
#488 - Jack Jacquemmoz / @MozJack

02/28/2014 at 01:47PM

37
#489 - Kris Hom / @krishom

04/04/2014 at 08:52PM

37
#490 - Richard Veneracion / @rveneracion

05/12/2014 at 12:27AM

37
#491 - Roy Vim / @RoyVim

09/25/2014 at 08:32AM

37
#492 - Daniel Pham / @dany_pham

10/14/2014 at 11:27PM

37
#493 - m1r4ge / @m1r4ge_ror

01/20/2015 at 12:19AM

37
#494 - Teemu Okkonen / @TeemuOkkonen

07/10/2015 at 08:19PM

37
#495 - Bogumił Kamiński / @BogumilKaminski

10/25/2015 at 04:02PM

37
#496 - Ben Hill / @KaizenSoze70

05/09/2016 at 01:07PM

37
#497 - Chris Armstrong / @ChrisATweets

05/20/2016 at 06:47PM

37
#498 - 王运 / @640138017

07/18/2016 at 01:56PM

37
#499 - Herbert S. / @herbertshlong

08/10/2016 at 12:31AM

37
#500 - mebubo / @mebubo

10/30/2016 at 12:18AM

37
#501 - Tom Houlé / @_tomhoule

05/15/2017 at 12:07PM

37
#502 - John Oleksowicz / @JohnOlek

10/09/2018 at 07:56PM

37
#503 - name / @name65894813

11/16/2018 at 04:44PM

37
#504 - hbdgr / @t_hbdgr

01/26/2019 at 08:07PM

37
#505 - 默罕默德 / @Rt6RjEAJ987Woes

02/20/2019 at 03:21AM

37
#506 - wanghbxxxx / @wanghbxxxx

04/07/2019 at 01:27PM

37
#507 - james_bunch / @james_bunch

04/20/2019 at 05:58AM

37
#508 - お薬手帳 / @iW4Wz6PpCiqyGqH

04/24/2019 at 05:54AM

38
#509 - Samus_ Michael / @gonna_hate

12/29/2010 at 02:40AM

38
#510 - Henri Bourcereau / @mmai

12/29/2010 at 11:41AM