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):
43
#871 - Kevin Etienne / @42__kevin

08/18/2013 at 06:45PM

43
#872 - Kostyantyn Leschenko / @settler_kos

08/19/2013 at 08:01AM

43
#873 - Tony Han / @tony612_han

08/31/2013 at 05:31AM

43
#874 - John Gray Cole / @johngraycole

12/08/2013 at 07:49PM

43
#875 - David M / @ohhhmandyyy

01/15/2014 at 11:35PM

43
#876 - Andreas Källberg / @Anka213

01/17/2014 at 12:06AM

43
#877 - Jonny / @Jonnytron

02/15/2014 at 05:20PM

43
#878 - wizardwerdna / @wizardwerdna

05/17/2014 at 08:46AM

43
#879 - Jake Eaton / @Jake__Eaton

06/01/2014 at 05:53AM

43
#880 - blamitter ✏️ / @blamitter

07/01/2014 at 09:21PM

43
#881 - Cameron Christensen / @csc89d

08/01/2014 at 03:26PM

43
#882 - Chris Trotman / @solarnz

10/06/2014 at 01:24AM

43
#883 - Shanky Surana / @shankysurana

11/28/2014 at 03:34AM

43
#884 - Angus Warren / @SuperJediWombat

01/23/2015 at 02:51PM

43
#885 - Sebastian B / @cyborgryna

02/03/2015 at 12:17AM

43
#886 - Elizabeth / @sprinkles418

04/17/2015 at 02:55PM

43
#887 - a / @robbietron

10/11/2015 at 07:53PM

43
#888 - Marty Boren / @computerliker

11/28/2015 at 03:23AM

43
#889 - Chenut Ludovic / @7Brwa7

03/31/2016 at 10:38AM

43
#890 - 白猫(zhu) / @cat2flower

06/04/2016 at 05:59PM

43
#891 - Constantine / @ConstantineHatz

09/20/2016 at 10:36PM

43
#892 - Cù Hữu Hoàng / @Cuhuuhoang

02/14/2017 at 05:08PM

43
#893 - caplod / @caplod

03/25/2017 at 12:07PM

43
#894 - lujianmei / @lujianmei

09/06/2017 at 09:26AM

43
#895 - Graham Bates / @gigabates

09/24/2017 at 08:34PM

43
#896 - Lisa Ugray / @lisa_ugray

03/15/2018 at 10:26PM

43
#897 - albalitz / @_albalitz

06/07/2019 at 12:54PM

43
#898 - mirsemen / @mirsemen1

07/16/2019 at 08:20AM

43
#899 - Christian / @paierlep

08/31/2019 at 08:48PM

43
#900 - Zach Ingbretsen / @ZIngbretsen

09/08/2019 at 10:51PM