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):
44
#931 - Charlene Tshos / @charlymul

04/09/2013 at 06:35PM

44
#932 - Balazs Nadasdi / @yitsushi

04/16/2013 at 06:46PM

44
#933 - ⚡ DRJ ⚡ / @midgetjones

06/08/2013 at 04:49PM

44
#934 - Dr. Rev. J. "Paranoid Android" Kirchartz / @JKirchartz

07/28/2013 at 08:15PM

44
#935 - cj / @cj01101

08/04/2013 at 02:09AM

44
#936 - Daniel Kovacic / @dkov01

09/02/2013 at 08:47PM

44
#937 - Brett Cassette / @brettcassette

12/01/2013 at 05:37AM

44
#938 - Devin V. / @enrual

12/15/2013 at 05:56AM

44
#939 - Pedro B. Coronel / @pbcoronel

01/28/2014 at 02:33AM

44
#940 - Chris Ciulla / @chris_ciulla

01/30/2014 at 01:48AM

44
#941 - Jae Won Kim / @jaewone

02/03/2014 at 07:29AM

44
#942 - Huang Yu / @trave7er

03/05/2014 at 05:24PM

44
#943 - Solar Powered Robot / @moskrin

05/01/2014 at 06:35PM

44
#944 - Harald H / @metellius

08/20/2014 at 10:21AM

44
#945 - Daniel Burnett / @mango_cheetah

10/10/2014 at 04:51PM

44
#946 - Aaron Whittington / @whittaaron

01/16/2015 at 03:09AM

44
#947 - Mark Saiget / @MarkSaiget

04/22/2015 at 03:34AM

44
#948 - Carsten Lenz / @carstenlenz

05/03/2015 at 06:12PM

44
#949 - Brian Besmanoff / @BrianBesmanoff

08/06/2015 at 05:34AM

44
#950 - Alex Bartol / @alexbartol

09/15/2015 at 06:05PM

44
#951 - Thomas Williams / @neopsalmist

01/06/2016 at 02:47PM

44
#952 - Clémence / @Clemence_Neoxia

05/23/2016 at 07:31AM

44
#953 - Will / @obiwan__k3n00bi

08/14/2016 at 10:47PM

44
#954 - Mark Brody / @_markbrody

03/23/2017 at 05:37AM

44
#955 - Geoff / @RealGeoffErwin

09/29/2017 at 06:52PM

44
#956 - たぬぽん / @eJYwMbymauWKF4B

06/11/2019 at 12:23PM

45
#957 - Jesse Brown / @bionicpill

12/29/2010 at 12:54AM

45
#958 - Jon Ferrer / @jonnyheadphones

01/02/2011 at 02:45AM

45
#959 - giggzy / @giggzy

08/13/2011 at 09:24PM

45
#960 - Jonathan Bennett / @jonbca7

11/24/2011 at 06:21AM