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

1374 active golfers, 5587 entries

Leaderboard (lowest score wins):
51
#1171 - Ben Wagaman / @jamin4jc

01/13/2012 at 04:23PM

51
#1172 - Julian / @ShumpEvenwood

11/25/2012 at 04:43PM

51
#1173 - Adam Bell / @adamgbell

02/13/2013 at 06:00PM

51
#1174 - Stephen Tindall / @stindall77

02/21/2013 at 06:02PM

51
#1175 - Ian Oxley / @ianoxley

10/23/2013 at 12:45PM

51
#1176 - adamblank / @adamblank

12/20/2013 at 07:42PM

51
#1177 - Caleb Perkins / @tollbooth

01/29/2014 at 07:38AM

51
#1178 - Marcin Cabaj / @marcincabaj

02/06/2014 at 01:59PM

51
#1179 - pawelmhm / @pawelmhm

03/01/2014 at 07:35PM

51
#1180 - Piotr Szeremeta / @Khamilowicz

02/08/2015 at 10:08PM

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

03/29/2015 at 10:45AM

51
#1182 - Thomas Draper / @QuanTom561

10/01/2015 at 11:10PM

51
#1183 - matty / @matty_books

12/26/2015 at 04:00PM

51
#1184 - Barespamtak / @barespamtak

09/11/2017 at 08:57AM

51
#1185 - 김형창 / @uVmEMZsCgcYvqZi

03/29/2019 at 06:33AM

51
#1186 - Tokos Apos / @AposTokosapos

11/04/2019 at 11:07AM

52
#1187 - drio / @drio

12/29/2010 at 11:19AM

52
#1188 - Mike Waldner / @mawaldne

12/31/2010 at 07:09PM

52
#1189 - Mateusz Zawisza / @mateuszzawisza

01/26/2011 at 01:54PM

52
#1190 - Matthieu Honel / @ocus

01/31/2011 at 11:34PM

52
#1191 - Mike Ballou / @ballou88

02/24/2011 at 10:32PM

52
#1192 - Esteban Ordano / @eordano

04/29/2011 at 07:28AM

52
#1193 - vgromainl / @vgromainl

07/23/2012 at 09:01PM

52
#1194 - Martin Muñoz / @iammmun

08/13/2012 at 06:23AM

52
#1195 - Denis Ivanov / @jumph4x

10/26/2012 at 10:04PM

52
#1196 - Cody Frazer / @crfrazer

11/07/2012 at 04:35PM

52
#1197 - Evan Shrubsole / @evanshrubsole

04/05/2013 at 04:15PM

52
#1198 - hafsteinn / @hafsteinn

05/19/2013 at 02:13PM

52
#1199 - Brian Peiris / @brianpeiris

12/28/2013 at 05:01AM

52
#1200 - Felix Boers / @felixboers

02/13/2014 at 09:01PM