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):
39
#601 - Joel Elkins / @dice_tea

03/11/2013 at 03:30PM

39
#602 - n2o4 / @scatotonic

03/16/2013 at 01:55PM

39
#603 - Goran Petrovity / @nasdukar

04/07/2013 at 09:40AM

39
#604 - Raphaël Pierquin / @perafoo

04/09/2013 at 02:44PM

39
#605 - David Gibson / @dgibson_

04/30/2013 at 11:58AM

39
#606 - Nathan / @NathanHarperoni

07/16/2013 at 08:16PM

39
#607 - Tullio Facchinetti / @toolleeo

08/02/2013 at 12:25PM

39
#608 - Alexander / @usr_noid

08/15/2013 at 08:20PM

39
#609 - Francois Picalausa / @fpicalausa

08/22/2013 at 04:49PM

39
#610 - Gwilym Kuiper / @gwilymk

09/24/2013 at 06:10PM

39
#611 - aRkadeFR / @aRkadeFR

10/03/2013 at 07:01AM

39
#612 - James O Smith / @josmith4242

10/27/2013 at 02:32AM

39
#613 - CarlMartin Rosenberg / @cmrosenberg

11/08/2013 at 01:48AM

39
#614 - evilmoe ☮ / @evilmoe

11/09/2013 at 11:36AM

39
#615 - Ban / @Rheriel

11/11/2013 at 11:42PM

39
#616 - Johan Berg / @_berg85

01/03/2014 at 12:19PM

39
#617 - mattsalacain / @mattsalacain

01/30/2014 at 10:13PM

39
#618 - Mike Marion / @mikejmarion

02/03/2014 at 10:33PM

39
#619 - Michal Keda / @adekcz

04/11/2014 at 10:52AM

39
#620 - Kyle Travis / @kmakai

05/19/2014 at 02:30PM

39
#621 - Dominik Szerszeń / @DominikSze

07/22/2014 at 03:45PM

39
#622 - Matthew Barrington / @mbarrin

07/30/2014 at 10:41PM

39
#623 - Keyboard Fire / @KeyboardFire

11/22/2014 at 02:51PM

39
#624 - Deepak Surti / @dmsurti

03/17/2015 at 01:04PM

39
#625 - Personal Life Trackr / @PersLifeTrackr

05/27/2015 at 09:51PM

39
#626 - Stefan Knudsen / @knud32

06/24/2015 at 02:16AM

39
#627 - Test / @goodbyetest1248

07/24/2015 at 05:15PM

39
#628 - John Clara / @johnanthclara

08/20/2015 at 06:42AM

39
#629 - Paulo Romeira / @pauloromeira

08/26/2015 at 07:22AM

39
#630 - Dian Xiao / @dian_xiao

10/11/2015 at 07:31PM