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

1792 active golfers, 7261 entries

Leaderboard (lowest score wins):
51
#1441 - pawelmhm / @pawelmhm

03/01/2014 at 07:35PM

51
#1442 - Piotr Szeremeta / @Khamilowicz

02/08/2015 at 10:08PM

51
#1443 - ಸುಬ್ರಹ್ಮಣ್ಯ ಜೋಶಿ / @subbucoding

03/29/2015 at 10:45AM

51
#1444 - Thomas Draper / @QuanTom561

10/01/2015 at 11:10PM

51
#1445 - matty / @matty_books

12/26/2015 at 04:00PM

51
#1446 - Barespamtak / @barespamtak

09/11/2017 at 08:57AM

51
#1447 - 김형창 / @uVmEMZsCgcYvqZi

03/29/2019 at 06:33AM

51
#1448 - Tokos Apos / @AposTokosapos

11/04/2019 at 11:07AM

51
#1449 - RockerZZY / @rocker_zzy

06/02/2020 at 01:38PM

51
#1450 - Jan Lukány / @Lukanyj

12/29/2020 at 01:00PM

51
#1451 - null / @err_not_nil

06/27/2023 at 04:28AM

51
#1452 - Andrew Karlovsky / @akarlovsky

01/10/2024 at 02:41AM

51
#1453 - Leemuns / @Leemuns

03/08/2024 at 03:18AM

51
#1454 - Ramon Wenger / @ramonwenger

04/18/2024 at 11:20AM

51
#1455 - Jaakko Saarinen / @pairofdice

05/09/2024 at 06:32PM

51
#1456 - ScrapingArt / @ScrapingArt

07/10/2024 at 08:30AM

51
#1457 - nixypanda / @nixypanda

12/29/2024 at 10:41AM

52
#1458 - drio / @drio

12/29/2010 at 11:19AM

52
#1459 - Mike Waldner / @mawaldne

12/31/2010 at 07:09PM

52
#1460 - Mateusz Zawisza / @mateuszzawisza

01/26/2011 at 01:54PM

52
#1461 - Matthieu Honel / @ocus

01/31/2011 at 11:34PM

52
#1462 - Mike Ballou / @ballou88

02/24/2011 at 10:32PM

52
#1463 - Esteban Ordano / @eordano

04/29/2011 at 07:28AM

52
#1464 - vgromainl / @vgromainl

07/23/2012 at 09:01PM

52
#1465 - Martin Muñoz / @iammmun

08/13/2012 at 06:23AM

52
#1466 - Denis Ivanov / @jumph4x

10/26/2012 at 10:04PM

52
#1467 - Cody Frazer / @crfrazer

11/07/2012 at 04:35PM

52
#1468 - Evan Shrubsole / @evanshrubsole

04/05/2013 at 04:15PM

52
#1469 - hafsteinn / @hafsteinn

05/19/2013 at 02:13PM

52
#1470 - Brian Peiris / @brianpeiris

12/28/2013 at 05:01AM