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):
42
#811 - matthew / @mdespuits

02/03/2012 at 06:51AM

42
#812 - Shane Emmons / @semmons99

02/10/2012 at 12:31PM

42
#813 - ümit kablan / @udslk

03/11/2012 at 02:03PM

42
#814 - Олег Коваленко / @oleg_kovalenko

04/01/2012 at 07:31AM

42
#815 - Tomas Frostensson / @frostensson

05/22/2012 at 03:16PM

42
#816 - noom narze / @NarzE

06/15/2012 at 11:27AM

42
#817 - Tanguy Antoine / @tanguyantoine

07/19/2012 at 01:11AM

42
#818 - Jingjing Duan / @duanjingjing

07/28/2012 at 12:15AM

42
#819 - XGOLFER / @vimg0lfer

01/04/2013 at 02:05AM

42
#820 - Ryan Scarbery / @ryan_scarbery

02/05/2013 at 06:26PM

42
#821 - くま55 / @kumack55

04/03/2013 at 07:52AM

42
#822 - Endel Dreyer / @endel

06/30/2013 at 04:49AM

42
#823 - TrentonZero / @TrentonZero

07/04/2013 at 09:24PM

42
#824 - David Tran / @everyzero

10/30/2013 at 07:57PM

42
#825 - Aaron Burrow / @WillFapForFood

12/20/2013 at 02:50PM

42
#826 - Domingue Justin / @_jdomingue

12/29/2013 at 08:29PM

42
#827 - Daniel Gray / @DanielFGray

01/07/2014 at 08:40PM

42
#828 - Michał Śliwoń / @mihcall

01/30/2014 at 01:25PM

42
#829 - freestlr / @freestlr

02/03/2014 at 09:22AM

42
#830 - Lucius L. Hilley III / @unkmar

02/27/2014 at 10:26AM

42
#831 - Fat troll / @fat_troll

03/29/2014 at 07:55AM

42
#832 - Shefaet / @shefaet

05/13/2014 at 11:54PM

42
#833 - Naoki Masuko / @nmasuko

07/11/2014 at 10:41PM

42
#834 - fa / @twiteciop

08/06/2014 at 07:43PM

42
#835 - Ene / @enesick

08/08/2014 at 11:47AM

42
#836 - Weijun He / @hewjun

08/31/2014 at 03:04PM

42
#837 - Giovanni Garufi / @garufi_giovanni

09/13/2014 at 10:56PM

42
#838 - Jose Gutierrez / @Jogusa

09/20/2014 at 11:25AM

42
#839 - Oliver Christ / @0liverChrist

01/12/2015 at 10:29PM

42
#840 - SilentFl / @Silent_Fl

01/27/2015 at 08:16AM