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):
47
#1051 - scturtle / @scturtle

04/12/2013 at 07:43AM

47
#1052 - Nick Rowe / @nixterrimus

05/15/2013 at 10:28PM

47
#1053 - Fl4t / @Fl4t

05/28/2013 at 09:34PM

47
#1054 - William / @wlmeng11

07/28/2013 at 05:33AM

47
#1055 - Hachez Floran / @FloranHachez

09/02/2013 at 05:05PM

47
#1056 - Anatolii Sakhnik / @sakhnik

09/30/2013 at 02:19PM

47
#1057 - Monroe Walker / @monroewlkr

10/16/2013 at 06:21AM

47
#1058 - Zachery Chin / @momochi0

11/05/2013 at 04:44AM

47
#1059 - mwcz / @mwcz

11/05/2013 at 08:05PM

47
#1060 - wilddog64 / @chengkai318

12/17/2013 at 03:51PM

47
#1061 - William Fligor / @williamfligor

01/28/2014 at 07:29PM

47
#1062 - Ronny Esterluss / @esterlus

01/29/2014 at 02:48PM

47
#1063 - João Paiva / @jgpaiva

01/29/2014 at 05:14PM

47
#1064 - Aidan Brumsickle / @aidanbrumsickle

03/26/2014 at 05:58PM

47
#1065 - Justin Thomas / @base698

04/18/2014 at 12:00AM

47
#1066 - Chris Davison / @davisonnn

05/25/2014 at 08:11PM

47
#1067 - Ch Ri / @szirocco

03/07/2015 at 09:54AM

47
#1068 - Antti A / @anttia

07/22/2015 at 03:37PM

47
#1069 - Sergey Semushin / @Predelnik

08/26/2015 at 06:04AM

47
#1070 - Joey / @joeyism101

09/03/2015 at 03:03PM

47
#1071 - Austin Wood / @indiesquidge

01/25/2016 at 05:54PM

47
#1072 - Pratap Koritala / @pratap_koritala

02/19/2016 at 07:53AM

47
#1073 - malet / @Malet

06/22/2016 at 07:40PM

47
#1074 - Nota Fool / @f970823

07/26/2016 at 06:04PM

47
#1075 - Thiago Belem / @TiuTalk

08/31/2016 at 03:58AM

47
#1076 - timerella® / @timerella

11/17/2016 at 12:13AM

47
#1077 - Миша Сорокин / @rafmikovi4

04/10/2017 at 11:33AM

47
#1078 - Jonas Sunde V / @sunde_v

08/04/2017 at 03:58PM

47
#1079 - Tim / @timothyscosta

03/09/2018 at 09:05AM

47
#1080 - niwatoco / @yoshitune9

07/19/2018 at 06:48PM