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):
36
#451 - John Karlsson / @karlssonjohn

01/28/2014 at 08:58PM

36
#452 - Jérémy Autran / @jjautran

01/29/2014 at 08:45PM

36
#453 - Zudov / @zudov_me

02/04/2014 at 07:36PM

36
#454 - Bart Nagel / @bjnagel

02/20/2014 at 09:27AM

36
#455 - フミ ハシ / @fumi_hs

02/21/2014 at 02:28PM

36
#456 - sprmgik / @sprmgik

03/14/2014 at 03:09AM

36
#457 - God / @iamgod

03/25/2014 at 01:55PM

36
#458 - Jeff / @just_geophree

03/29/2014 at 09:22PM

36
#459 - onthos / @onthos_

04/25/2014 at 10:47AM

36
#460 - Shawn / @ShawnSquire

06/05/2014 at 06:09PM

36
#461 - Caek / @Caek_

08/12/2014 at 04:42AM

36
#462 - CJ Avilla / @cjav_dev

11/09/2014 at 08:01PM

36
#463 - Charles Joachim / @cacplate

04/19/2015 at 10:15PM

36
#464 - Roben Kleene / @robenkleene

07/31/2015 at 12:59AM

36
#465 - John Diamond / @jcdmnd

08/14/2015 at 03:43PM

36
#466 - Nicolas Nistal / @niconistal

11/19/2015 at 12:44AM

36
#467 - Alex Ch / @_AlexCh_

03/31/2016 at 10:35PM

36
#468 - Atrament / @Atrament

05/11/2016 at 03:25PM

36
#469 - Mateusz / @Mantos77

09/05/2016 at 12:34AM

36
#470 - Carl Egbert / @CarlOEgbert

06/09/2017 at 09:36PM

36
#471 - Bennett Bernardoni / @BBernardoni

06/28/2017 at 07:32PM

36
#472 - Matti Sairanen / @MattiSairanen

08/03/2017 at 11:28AM

36
#473 - しぇぱっち / @shepabashi

10/23/2017 at 05:58AM

36
#474 - BareTull / @BareTull3

12/04/2017 at 01:37PM

36
#475 - tPenguinLTG / @tpenguinltg

01/16/2018 at 04:51PM

36
#476 - DHM / @DHM29978992

04/13/2018 at 02:37AM

36
#477 - Brendan B Amdocs / @AmdocsB

09/28/2018 at 04:08PM

36
#478 - Roger Bongers / @RogerBongers

10/06/2018 at 05:41PM

36
#479 - Martin Delille / @martinodelilo

08/24/2019 at 01:49PM

36
#480 - howanto / @ho_wan_

02/23/2020 at 01:34PM