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):
59
#1291 - Luis Rodriguez / @luisthecoder

11/13/2018 at 03:37AM

60
#1292 - Unsouled / @unsouled0

12/30/2010 at 02:52AM

60
#1293 - Tomo.H / @joker1007

04/24/2011 at 08:01AM

60
#1294 - quintin / @quintinjeannoel

08/29/2011 at 07:35AM

60
#1295 - sathish316 / @sathish316

11/18/2012 at 04:55PM

60
#1296 - CHIP CASTLE / @chipcastle

12/27/2013 at 04:06AM

60
#1297 - Di Peng / @DCodier

11/03/2018 at 02:09AM

60
#1298 - Jasper Pangilinan / @JasperP

12/31/2018 at 12:46AM

61
#1299 - uɥoɾ / @retr0h

12/28/2010 at 08:13PM

61
#1300 - Pratik Prasad / @pratik

05/03/2017 at 01:40PM

62
#1301 - Jean-Christophe Cyr / @jccyr01

05/28/2011 at 12:39AM

62
#1302 - Matthew Cupps / @matthewcupps

12/20/2011 at 11:58PM

62
#1303 - Eric Kelly / @HeroicEric

02/14/2012 at 03:57PM

62
#1304 - korzenmichal / @korzenmichal

05/16/2017 at 10:08PM

62
#1305 - IHateTweeting999 / @ITweeting999

05/05/2019 at 08:32PM

63
#1306 - Dave Bradford / @dbradf

06/17/2011 at 11:00PM

63
#1307 - Tom Cowling / @tlcowling

01/30/2013 at 04:46PM

63
#1308 - Sime Buljac / @sim_bul

10/09/2015 at 04:01PM

63
#1309 - Feras / @faldah

04/24/2016 at 06:03AM

64
#1310 - venkatakrishnan / @venkatk_

08/19/2013 at 02:43PM

64
#1311 - Larijohn Adorable / @jbpnoy6fifty

01/31/2014 at 10:47AM

65
#1312 - Jay Phillips / @jicksta

01/03/2011 at 06:28PM

65
#1313 - 杨洋 / @176795444

08/14/2017 at 12:01PM

66
#1314 - Michael Coles / @gen_ale_drinker

08/13/2013 at 12:41PM

67
#1315 - Adriano Bonat / @tanob

01/09/2011 at 10:40PM

67
#1316 - Duy Vinh CHUC / @french_vinh

12/10/2011 at 04:05PM

67
#1317 - Leif Bladt / @leifbladt

08/27/2013 at 11:55AM

68
#1318 - Julian / @naydichev

12/28/2010 at 11:35PM

68
#1319 - lionel young / @lionelyoung

12/29/2010 at 12:44AM

68
#1320 - Ilya Grigorik / @igrigorik

12/31/2010 at 08:07PM