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
#901 - Brandon Harrison / @llAboutB

09/24/2019 at 08:29PM

43
#902 - Lorenzo Bertolino / @lo_bertolino

09/25/2019 at 04:37PM

44
#903 - 東 / @lldong

12/29/2010 at 08:08AM

44
#904 - kkaefer / @kkaefer

12/29/2010 at 11:11AM

44
#905 - Anders H. Madsen / @andershellerup

01/03/2011 at 07:27PM

44
#906 - yc_p / @yc_p

01/04/2011 at 08:37PM

44
#907 - Stephen Brandwood / @sbrandwoo

01/08/2011 at 06:19PM

44
#908 - Alekseyka2 / @Alekseyka2

01/25/2011 at 02:24PM

44
#909 - Steve Newell / @newellista

03/18/2011 at 03:04PM

44
#910 - Masashi Iizuka / @uochan

04/03/2011 at 02:13AM

44
#911 - Mario Scheliga / @marioscheliga

05/14/2011 at 10:59PM

44
#912 - Justin Hale / @jxl

05/27/2011 at 08:27AM

44
#913 - Martin Lundberg / @marlun

05/30/2011 at 10:43AM

44
#914 - David Kormushoff / @Kormie

07/08/2011 at 04:46AM

44
#915 - Simon's Calf / @simonscarfe

08/30/2011 at 02:22PM

44
#916 - Sam Haskins / @samhaskins

09/16/2011 at 04:51PM

44
#917 - Alex Croteau-Pothier / @AlexCP_

12/10/2011 at 12:05AM

44
#918 - Craig Martek / @cregatron

01/26/2012 at 04:09PM

44
#919 - Tim Blair / @timblair

02/16/2012 at 10:27AM

44
#920 - lucapette / @lucapette

04/26/2012 at 10:04PM

44
#921 - Matt / @eastcoastbum

05/25/2012 at 05:43AM

44
#922 - Benjamin Sergeant / @bsergean

06/04/2012 at 04:05AM

44
#923 - Enrique García / @otikik

06/12/2012 at 10:10PM

44
#924 - metaphract / @metaphract

07/28/2012 at 07:34PM

44
#925 - ') DROP TABLE user; / @_ckafi

08/19/2012 at 01:34PM

44
#926 - Ravi S Sinha / @ambidextrousTx

08/29/2012 at 08:24AM

44
#927 - Vicente Sánchez / @froysm

09/09/2012 at 06:14AM

44
#928 - Domon / @Domon

09/11/2012 at 05:59AM

44
#929 - Brenno Costa / @brennovich

09/30/2012 at 10:51PM

44
#930 - Matt Burrows / @dic3m4n

12/19/2012 at 10:11AM