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 1753 remaining solutions by signing in and submitting your own entry
#1754 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

1754 active golfers, 7154 entries

Leaderboard (lowest score wins):
35
#361 - gary.klindt@googlema / @garstekli

11/12/2013 at 06:43PM

35
#362 - Fake Name / @The_Real_User

01/07/2014 at 03:38AM

35
#363 - Quota / @Quotad

01/10/2014 at 01:29PM

35
#364 - Arsenic Hall / @FoxLisk

01/28/2014 at 11:58PM

35
#365 - JamesT / @jamestrinklein

01/29/2014 at 09:15AM

35
#366 - Yongho / @YONG_HO

02/06/2014 at 10:17AM

35
#367 - Joonas Pihlajamaa / @jokkebk

02/08/2014 at 11:26PM

35
#368 - Hannes Remahl / @hannesr

02/27/2014 at 04:17PM

35
#369 - William Snyders / @iam2391212

03/05/2014 at 12:10AM

35
#370 - Norm Fasey / @DeathRay1977

05/02/2014 at 09:13PM

35
#371 - Mauro Persano / @fzort

11/16/2014 at 10:19AM

35
#372 - Test User / @TestUserIgnore

12/04/2014 at 11:22PM

35
#373 - David Han / @HanDavid

12/07/2014 at 04:03AM

35
#374 - Sntano Euhsk / @SEuhsk

01/15/2015 at 11:21PM

35
#375 - TheProgrammer971 / @tp971

03/14/2015 at 02:22AM

35
#376 - Faat / @i_faat

01/29/2016 at 01:45PM

35
#377 - James Burns / @James_Ian_Burns

02/21/2016 at 02:54PM

35
#378 - Yahyalexandre33 / @yahyalexandre33

03/15/2016 at 07:57AM

35
#379 - S O / @strangelooperer

04/17/2016 at 09:04PM

35
#380 - Håkon Bråten / @h_braten

04/26/2016 at 03:52PM

35
#381 - Andres Araya / @arayaandresfco

05/15/2016 at 07:41PM

35
#382 - (,,꒪꒫꒪,,) / @sneer

05/22/2016 at 07:38AM

35
#383 - Jan Bundesmann / @janbundesmann

05/31/2016 at 12:44PM

35
#384 - Reuben Huxley / @missiontocode

06/29/2016 at 09:51PM

35
#385 - TweetDreams / @TweetMusicians

10/08/2016 at 10:16PM

35
#386 - Benoit Mortgat / @Benoit_Mortgat

11/14/2017 at 10:49AM

35
#387 - Eric Liao / @rcliaodev

12/07/2017 at 07:30AM

35
#388 - herbage / @herbage2

01/03/2018 at 09:04PM

35
#389 - Guirec CORBEL / @GuirecCorbel

03/07/2018 at 11:09AM

35
#390 - Daniël De Koker / @daniel_koker

07/01/2018 at 12:51PM