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

1312 active golfers, 5363 entries

Leaderboard (lowest score wins):
38
#541 - John / @BerlinSchneider

01/18/2014 at 09:05PM

38
#542 - Daniel Jonsson / @DanielJonss

01/21/2014 at 04:33PM

38
#543 - André / @Joschasa

01/22/2014 at 03:05PM

38
#544 - Jakob Lundberg / @JakobLundberg

01/31/2014 at 11:02AM

38
#545 - Ali El Amine / @Allouch95

02/02/2014 at 11:52AM

38
#546 - Joshua Tacoma / @yellowseed

02/02/2014 at 03:44PM

38
#547 - Ri / @riateche

03/02/2014 at 01:07PM

38
#548 - Lasse Dalegaard / @ldalegaard

07/07/2014 at 06:10AM

38
#549 - Michi Loro / @michiloro

07/08/2014 at 11:45AM

38
#550 - Oleg Tsymbalyuk / @oleg_tc

07/11/2014 at 05:17AM

38
#551 - Daniel / @dazn159

08/15/2014 at 09:55PM

38
#552 - AC / @quadface

08/21/2014 at 02:58PM

38
#553 - Rao Zvorovski / @RaoZvorovski

12/07/2014 at 01:08AM

38
#554 - Tom van der Lee / @TomVdLee

04/17/2015 at 10:01AM

38
#555 - Adetque / @Adetque

05/29/2015 at 09:41AM

38
#556 - Blake Tereau / @BlakeTereau

08/15/2015 at 10:08PM

38
#557 - Charles Martin / @instinctive

10/07/2015 at 07:42AM

38
#558 - ryo_n / @ryo_n

02/10/2016 at 08:28AM

38
#559 - Jonathan Elliott / @jon__elliott

11/02/2016 at 01:40AM

38
#560 - Vojtěch Vobr / @vvobr

12/04/2016 at 03:02PM

38
#561 - Hans Yelek / @hans_yelek

01/10/2017 at 03:47AM

38
#562 - aa / @aassaad93

07/18/2017 at 05:16AM

38
#563 - RustingSword / @RustingSword

08/18/2017 at 01:51AM

38
#564 - Mihai / @mihaicristiant

12/03/2018 at 10:32AM

38
#565 - Timur Celik / @clktmr

12/21/2018 at 04:54PM

38
#566 - Andreas Nordahl / @andreasnordahl

01/03/2019 at 10:24AM

39
#567 - Mirosław Boruta / @m1rk00

12/28/2010 at 08:41PM

39
#568 - 藤田祥 / Sho Fujita / @fujisho

12/31/2010 at 11:58AM

39
#569 - Matt Tarbit / @mtarbitdev

01/06/2011 at 10:47PM

39
#570 - Adrian Silva / @scyldinga

01/12/2011 at 10:58PM