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

1401 active golfers, 5698 entries

Leaderboard (lowest score wins):
41
#811 - Matt Aschmann / @ma7hatter

12/30/2019 at 06:44PM

41
#812 - Karnival K / @K4rnival

01/15/2020 at 07:16PM

41
#813 - Jason Neylon / @jasonneylon

01/18/2020 at 01:43PM

41
#814 - Jason / @roosjason

04/25/2020 at 11:08AM

41
#815 - Jeff Cui / @jeffacce

05/13/2020 at 10:35AM

41
#816 - Pham Tuan Anh / @anhpt379

06/28/2020 at 09:12PM

42
#817 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 03:57PM

42
#818 - Jarkko Laine / @jarkko

12/29/2010 at 07:18PM

42
#819 - emmanuel delgado / @chischaschos

01/03/2011 at 12:37AM

42
#820 - Ben Bleything / @bleything

01/05/2011 at 08:57PM

42
#821 - Michael Yasumoto / @yasumotouw

01/11/2011 at 08:28PM

42
#822 - Kai Wood / @kwd_io

04/04/2011 at 11:07AM

42
#823 - Craig H. Anderson / @CootCraig

04/17/2011 at 08:05AM

42
#824 - Hervo Manuel / @Azema31

05/18/2011 at 06:43PM

42
#825 - Pete Brown / @beerlington

06/03/2011 at 03:44AM

42
#826 - marssong / @marssong

10/10/2011 at 11:23AM

42
#827 - Nathan Ehresman / @nehresman

11/16/2011 at 07:54PM

42
#828 - Sergii Galashyn / @sgalashyn

12/21/2011 at 11:47AM

42
#829 - suhair hassan / @suhairhassan

12/27/2011 at 11:16AM

42
#830 - GiaNU / @sgianazza

01/31/2012 at 03:30PM

42
#831 - matthew / @mdespuits

02/03/2012 at 06:51AM

42
#832 - Shane Emmons / @semmons99

02/10/2012 at 12:31PM

42
#833 - ümit kablan / @udslk

03/11/2012 at 02:03PM

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

04/01/2012 at 07:31AM

42
#835 - Tomas Frostensson / @frostensson

05/22/2012 at 03:16PM

42
#836 - noom narze / @NarzE

06/15/2012 at 11:27AM

42
#837 - Tanguy Antoine / @tanguyantoine

07/19/2012 at 01:11AM

42
#838 - Jingjing Duan / @duanjingjing

07/28/2012 at 12:15AM

42
#839 - XGOLFER / @vimg0lfer

01/04/2013 at 02:05AM

42
#840 - Ryan Scarbery / @ryan_scarbery

02/05/2013 at 06:26PM