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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
37
#541 - A. N. / @arez42

10/24/2013 at 06:16AM

37
#542 - Zach Kemp / @zvksf

12/13/2013 at 10:43PM

37
#543 - Amir Kremer / @AmirKremer

01/28/2014 at 01:53PM

37
#544 - John Phelan / @jackphel

02/02/2014 at 07:30PM

37
#545 - Seán Kelleher / @eZanmoto

02/04/2014 at 05:19PM

37
#546 - rocpatel / @rocpatel

02/10/2014 at 02:53PM

37
#547 - Spencer McAlpine / @spencermcalpine

02/11/2014 at 03:05PM

37
#548 - Will / @VVi11_I_AM

02/16/2014 at 04:37AM

37
#549 - Robert Siemieniec / @rsiemieniec

02/18/2014 at 02:51PM

37
#550 - Jack Jacquemmoz / @MozJack

02/28/2014 at 01:47PM

37
#551 - Kris Hom / @krishom

04/04/2014 at 08:52PM

37
#552 - Richard Veneracion / @rveneracion

05/12/2014 at 12:27AM

37
#553 - Roy Vim / @RoyVim

09/25/2014 at 08:32AM

37
#554 - Daniel Pham / @dany_pham

10/14/2014 at 11:27PM

37
#555 - m1r4ge / @m1r4ge_ror

01/20/2015 at 12:19AM

37
#556 - Teemu Okkonen / @TeemuOkkonen

07/10/2015 at 08:19PM

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

10/25/2015 at 04:02PM

37
#558 - Ben Hill / @KaizenSoze70

05/09/2016 at 01:07PM

37
#559 - Chris Armstrong / @ChrisATweets

05/20/2016 at 06:47PM

37
#560 - 王运 / @640138017

07/18/2016 at 01:56PM

37
#561 - Herbert S. / @herbertshlong

08/10/2016 at 12:31AM

37
#562 - mebubo / @mebubo

10/30/2016 at 12:18AM

37
#563 - Tom Houlé / @_tomhoule

05/15/2017 at 12:07PM

37
#564 - John Oleksowicz / @JohnOlek

10/09/2018 at 07:56PM

37
#565 - name / @name65894813

11/16/2018 at 04:44PM

37
#566 - hbdgr / @t_hbdgr

01/26/2019 at 08:07PM

37
#567 - 默罕默德 / @Rt6RjEAJ987Woes

02/20/2019 at 03:21AM

37
#568 - wanghbxxxx / @wanghbxxxx

04/07/2019 at 01:27PM

37
#569 - james_bunch / @james_bunch

04/20/2019 at 05:58AM

37
#570 - お薬手帳 / @iW4Wz6PpCiqyGqH

04/24/2019 at 05:54AM