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):
46
#1021 - Ryan Glassett / @rollsavager

10/23/2014 at 12:57AM

46
#1022 - Christian Kjær / @christian_kjaer

12/13/2014 at 11:57PM

46
#1023 - adrien frediani / @fredianiadrien

12/16/2015 at 08:15PM

46
#1024 - Craig Hills / @chills42

03/05/2016 at 02:34AM

46
#1025 - Timothy Caleb Nordlo / @tnordloh

06/27/2016 at 04:45AM

46
#1026 - Michał Kordas / @michal_kordas

09/19/2016 at 07:46PM

46
#1027 - Patrick Davey / @psdavey

10/26/2016 at 12:31PM

46
#1028 - Gurukandhamoorthi / @Gurukandhamoor1

07/10/2017 at 11:52AM

46
#1029 - Terry Ding / @TerryDing77

08/24/2017 at 11:03AM

46
#1030 - Jonathan Camilleri / @Too_Many_Taken

05/24/2018 at 02:54PM

46
#1031 - Oren Koriat / @KoriatOren

12/13/2018 at 09:14PM

47
#1032 - Felipe Nakandakari / @fenak

12/28/2010 at 09:32PM

47
#1033 - Ben Lenarts / @benlenarts

12/29/2010 at 04:07PM

47
#1034 - Thomas Schönwälder / @Masei1988

01/15/2011 at 06:17PM

47
#1035 - Hannibal7878 / @Hannibal7878

02/15/2011 at 11:47PM

47
#1036 - Jack Kinsella / @jackkinsella

07/10/2011 at 07:04PM

47
#1037 - William Hua / @attente

07/17/2011 at 12:06PM

47
#1038 - Gar Morley / @garmorley

12/17/2011 at 05:38PM

47
#1039 - rajesh parvathaneni / @rparvathaneni

01/10/2012 at 12:05AM

47
#1040 - Alexander Soborov / @excelenter

01/16/2012 at 04:29PM

47
#1041 - João Veiga / @jcsvveiga

02/12/2012 at 11:52AM

47
#1042 - Jeremy Voorhis / @jvoorhis

02/14/2012 at 11:30PM

47
#1043 - ise0615 / @ise0615

05/04/2012 at 04:12PM

47
#1044 - Patrik Björklund / @pbjorklund

06/15/2012 at 02:42PM

47
#1045 - Richard / @crazyyoss

08/29/2012 at 11:57PM

47
#1046 - Stephen / @StephenPek

10/04/2012 at 03:15AM

47
#1047 - Kirill / @wedens_

11/19/2012 at 09:00AM

47
#1048 - Matthew Paul / @gilbrilthor

12/17/2012 at 04:41PM

47
#1049 - welbjo / @welbjo

01/23/2013 at 10:41PM

47
#1050 - Pieter Kuijpers / @pkuijpers

03/07/2013 at 09:42PM