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):
51
#1171 - Ian Oxley / @ianoxley

10/23/2013 at 12:45PM

51
#1172 - adamblank / @adamblank

12/20/2013 at 07:42PM

51
#1173 - Caleb Perkins / @tollbooth

01/29/2014 at 07:38AM

51
#1174 - Marcin Cabaj / @marcincabaj

02/06/2014 at 01:59PM

51
#1175 - pawelmhm / @pawelmhm

03/01/2014 at 07:35PM

51
#1176 - Piotr Szeremeta / @Khamilowicz

02/08/2015 at 10:08PM

51
#1177 - ಸುಬ್ರಹ್ಮಣ್ಯ ಜೋಶಿ / @subbucoding

03/29/2015 at 10:45AM

51
#1178 - Thomas Draper / @QuanTom561

10/01/2015 at 11:10PM

51
#1179 - matty / @matty_books

12/26/2015 at 04:00PM

51
#1180 - Barespamtak / @barespamtak

09/11/2017 at 08:57AM

51
#1181 - 김형창 / @uVmEMZsCgcYvqZi

03/29/2019 at 06:33AM

51
#1182 - Tokos Apos / @AposTokosapos

11/04/2019 at 11:07AM

52
#1183 - drio / @drio

12/29/2010 at 11:19AM

52
#1184 - Mike Waldner / @mawaldne

12/31/2010 at 07:09PM

52
#1185 - Mateusz Zawisza / @mateuszzawisza

01/26/2011 at 01:54PM

52
#1186 - Matthieu Honel / @ocus

01/31/2011 at 11:34PM

52
#1187 - Mike Ballou / @ballou88

02/24/2011 at 10:32PM

52
#1188 - Esteban Ordano / @eordano

04/29/2011 at 07:28AM

52
#1189 - vgromainl / @vgromainl

07/23/2012 at 09:01PM

52
#1190 - Martin Muñoz / @iammmun

08/13/2012 at 06:23AM

52
#1191 - Denis Ivanov / @jumph4x

10/26/2012 at 10:04PM

52
#1192 - Cody Frazer / @crfrazer

11/07/2012 at 04:35PM

52
#1193 - Evan Shrubsole / @evanshrubsole

04/05/2013 at 04:15PM

52
#1194 - hafsteinn / @hafsteinn

05/19/2013 at 02:13PM

52
#1195 - Brian Peiris / @brianpeiris

12/28/2013 at 05:01AM

52
#1196 - Felix Boers / @felixboers

02/13/2014 at 09:01PM

52
#1197 - Tj / @yrddy

08/13/2014 at 06:58AM

52
#1198 - luffy / @raxcoi

06/06/2015 at 04:31PM

52
#1199 - Christian Albertsen / @mannahusum

02/24/2016 at 02:45PM

52
#1200 - iNaKoll / @iNaKoll

05/07/2016 at 07:03PM