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):
52
#1471 - Felix Boers / @felixboers

02/13/2014 at 09:01PM

52
#1472 - Tj / @yrddy

08/13/2014 at 06:58AM

52
#1473 - luffy / @raxcoi

06/06/2015 at 04:31PM

52
#1474 - Christian Albertsen / @mannahusum

02/24/2016 at 02:45PM

52
#1475 - iNaKoll / @iNaKoll

05/07/2016 at 07:03PM

52
#1476 - Pierre Maoui / @p_maoui

12/17/2016 at 04:20PM

52
#1477 - Ilya Shakirov / @aelaau

03/20/2017 at 09:35AM

52
#1478 - Jenny Johnson / @Kippz07

05/12/2017 at 03:16PM

52
#1479 - Adam Matan / @adam_matan

07/31/2017 at 10:26PM

52
#1480 - alekfed / @alek_fed

04/15/2019 at 08:10AM

52
#1481 - Kai.Li / @KaiLi19

05/07/2019 at 05:46AM

52
#1482 - Sam Unicomb / @samuelunicomb

12/28/2022 at 05:36PM

52
#1483 - Jorge Peña / @wkynrocks

02/22/2024 at 12:28AM

52
#1484 - Thermospore / @Thermospore

05/21/2024 at 11:47AM

52
#1485 - Fabrice Tsiava / @FabriceTsiava

09/08/2024 at 02:23PM

52
#1486 - Brando / @brandonce

01/09/2025 at 09:09AM

52
#1487 - P1NGG / @P1NGG

04/19/2025 at 02:25PM

52
#1488 - Henry Coggins / @hcoggins

07/05/2025 at 12:18PM

53
#1489 - Cristi Balan / @evilchelu

12/28/2010 at 08:44PM

53
#1490 - Jonathan Perret / @jonathanperret

12/28/2010 at 09:07PM

53
#1491 - Zhao Yao / @Lynch8080

12/31/2010 at 07:01PM

53
#1492 - khebbie / @khebbie

06/16/2011 at 06:51PM

53
#1493 - Dave / @zzdave13

07/15/2011 at 10:49AM

53
#1494 - Scott Nielsen / @smniel

03/28/2012 at 08:11AM

53
#1495 - 蒼時弦也 / @elct9620

03/29/2012 at 11:00AM

53
#1496 - Corey Glynn / @albedoa

10/10/2012 at 02:14AM

53
#1497 - Paul Jay / @PaulJay91

03/15/2014 at 03:50AM

53
#1498 - Glauco Pires / @grpires

11/25/2014 at 01:07PM

53
#1499 - Izabel Jelenić / @IzabelJelenic

12/22/2015 at 08:51PM

53
#1500 - Austin Ware / @AustinWare17

03/12/2018 at 08:28PM