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):
60
#1291 - sathish316 / @sathish316

11/18/2012 at 04:55PM

60
#1292 - CHIP CASTLE / @chipcastle

12/27/2013 at 04:06AM

60
#1293 - Di Peng / @DCodier

11/03/2018 at 02:09AM

60
#1294 - Jasper Pangilinan / @JasperP

12/31/2018 at 12:46AM

61
#1295 - uɥoɾ / @retr0h

12/28/2010 at 08:13PM

61
#1296 - Pratik Prasad / @pratik

05/03/2017 at 01:40PM

62
#1297 - Jean-Christophe Cyr / @jccyr01

05/28/2011 at 12:39AM

62
#1298 - Matthew Cupps / @matthewcupps

12/20/2011 at 11:58PM

62
#1299 - Eric Kelly / @HeroicEric

02/14/2012 at 03:57PM

62
#1300 - korzenmichal / @korzenmichal

05/16/2017 at 10:08PM

62
#1301 - IHateTweeting999 / @ITweeting999

05/05/2019 at 08:32PM

63
#1302 - Dave Bradford / @dbradf

06/17/2011 at 11:00PM

63
#1303 - Tom Cowling / @tlcowling

01/30/2013 at 04:46PM

63
#1304 - Sime Buljac / @sim_bul

10/09/2015 at 04:01PM

63
#1305 - Feras / @faldah

04/24/2016 at 06:03AM

64
#1306 - venkatakrishnan / @venkatk_

08/19/2013 at 02:43PM

64
#1307 - Larijohn Adorable / @jbpnoy6fifty

01/31/2014 at 10:47AM

65
#1308 - Jay Phillips / @jicksta

01/03/2011 at 06:28PM

65
#1309 - 杨洋 / @176795444

08/14/2017 at 12:01PM

66
#1310 - Michael Coles / @gen_ale_drinker

08/13/2013 at 12:41PM

67
#1311 - Adriano Bonat / @tanob

01/09/2011 at 10:40PM

67
#1312 - Duy Vinh CHUC / @french_vinh

12/10/2011 at 04:05PM

67
#1313 - Leif Bladt / @leifbladt

08/27/2013 at 11:55AM

68
#1314 - Julian / @naydichev

12/28/2010 at 11:35PM

68
#1315 - lionel young / @lionelyoung

12/29/2010 at 12:44AM

68
#1316 - Ilya Grigorik / @igrigorik

12/31/2010 at 08:07PM

68
#1317 - A / @a_akessler

12/11/2012 at 09:04PM

68
#1318 - ryk / @rykarn

03/29/2014 at 01:11PM

69
#1319 - Yu-Hsuan Li / @Walker_tw

12/21/2011 at 07:11AM

70
#1320 - david / @ultrayoshi

12/31/2010 at 07:51PM