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

1456 active golfers, 5889 entries

Leaderboard (lowest score wins):
38
#601 - sooqua / @sooqua

08/08/2019 at 09:14PM

38
#602 - Adam Hartz / @awareofnow

08/28/2019 at 02:07AM

38
#603 - Cassandra / @kascein

09/17/2019 at 07:11PM

38
#604 - nefforr / @yayamip

09/25/2019 at 03:48AM

38
#605 - Viktor Styrud / @ViktorStyrud

10/07/2019 at 01:16PM

38
#606 - Felix / @motorente

06/27/2020 at 07:08AM

38
#607 - Tobi Tesuji / @TobiTesuji

05/15/2021 at 09:31PM

38
#608 - Lynn / @chordbug

08/02/2021 at 06:47PM

38
#609 - Jean George / @JeanGeo20504212

09/18/2021 at 07:48PM

39
#610 - Mirosław Boruta / @m1rk00

12/28/2010 at 08:41PM

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

12/31/2010 at 11:58AM

39
#612 - Matt Tarbit / @mtarbitdev

01/06/2011 at 10:47PM

39
#613 - Adrian Silva / @scyldinga

01/12/2011 at 10:58PM

39
#614 - Nick / @quinks25

01/13/2011 at 04:04AM

39
#615 - Rob Ciaccio / @RobertoCalavera

01/14/2011 at 05:39PM

39
#616 - Wesley Wong / @wesleymwwong

01/28/2011 at 08:37AM

39
#617 - vg / @vimgolfer

02/19/2011 at 09:59PM

39
#618 - xaizek / @xaizek

02/26/2011 at 08:38PM

39
#619 - Nomen Nescio / @vadtusan

04/14/2011 at 07:49AM

39
#620 - Wim Looman / @Nemo157

06/06/2011 at 11:16AM

39
#621 - José Mota / @josemotanet

06/09/2011 at 12:29PM

39
#622 - Glenn / @glennular

07/18/2011 at 12:38AM

39
#623 - Petrik de Heus / @four54

08/22/2011 at 06:17PM

39
#624 - Dmitry Bashkatov / @dbashkatov

10/31/2011 at 08:37AM

39
#625 - Infertux / @Infertux

11/04/2011 at 04:45PM

39
#626 - Samnang Chhun / @samnangchhun

11/24/2011 at 06:48AM

39
#627 - Mislav Marohnić / @mislav

12/05/2011 at 05:27PM

39
#628 - Oscar Del Ben / @oscardelben

12/12/2011 at 01:00AM

39
#629 - Jey Balachandran / @jeybala

12/23/2011 at 02:36AM

39
#630 - Raúl Pedroche / @pedrocheisback

02/07/2012 at 08:34PM