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):
41
#781 - 親の金でシャンプーを買うな / @jajkeqos

04/08/2015 at 04:04PM

41
#782 - chvzvhn / @chvzvhn

04/26/2015 at 06:33AM

41
#783 - Grisha Pushkov / @readoonly

05/14/2015 at 08:31AM

41
#784 - Daxin / @Daxin2010

09/28/2015 at 02:01PM

41
#785 - Pete Sevander / @Sevanteri

11/11/2015 at 10:56AM

41
#786 - Jakob Schöttl / @jschoettl

12/21/2015 at 02:46AM

41
#787 - Sebastian Pfluegelm / @sebastian_pflgl

06/22/2016 at 07:44PM

41
#788 - Peter Gundel / @GundelMail

05/15/2017 at 11:42AM

41
#789 - Ron Alexssen / @Ralexhere

10/30/2017 at 06:31AM

41
#790 - Evgeny`s Kindle / @EvgenyKindle

04/24/2018 at 10:06AM

41
#791 - Rakesh P / @rakeshpgopal

05/23/2018 at 06:03PM

41
#792 - Kris Ezra / @kris_ezra

09/12/2018 at 03:39AM

41
#793 - Dryvnt / @Dryvnt

04/04/2019 at 01:20PM

41
#794 - Simon Zeng / @KronicMan

06/15/2019 at 05:01PM

41
#795 - Iggy / @iggredible

10/24/2019 at 02:51AM

41
#796 - Lory / @Lory46845742

11/08/2019 at 08:36AM

42
#797 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 03:57PM

42
#798 - Jarkko Laine / @jarkko

12/29/2010 at 07:18PM

42
#799 - emmanuel delgado / @chischaschos

01/03/2011 at 12:37AM

42
#800 - Ben Bleything / @bleything

01/05/2011 at 08:57PM

42
#801 - Michael Yasumoto / @yasumotouw

01/11/2011 at 08:28PM

42
#802 - Kai Wood / @kwd_io

04/04/2011 at 11:07AM

42
#803 - Craig H. Anderson / @CootCraig

04/17/2011 at 08:05AM

42
#804 - Hervo Manuel / @Azema31

05/18/2011 at 06:43PM

42
#805 - Pete Brown / @beerlington

06/03/2011 at 03:44AM

42
#806 - marssong / @marssong

10/10/2011 at 11:23AM

42
#807 - Nathan Ehresman / @nehresman

11/16/2011 at 07:54PM

42
#808 - Sergii Galashyn / @sgalashyn

12/21/2011 at 11:47AM

42
#809 - suhair hassan / @suhairhassan

12/27/2011 at 11:16AM

42
#810 - GiaNU / @sgianazza

01/31/2012 at 03:30PM