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):
40
#841 - eirc / @eirc

01/24/2015 at 01:33PM

40
#842 - Ala' Ibrahim / @alaa_ibrahim

03/10/2015 at 10:32AM

40
#843 - Robin Moussu / @robin_moussu

03/30/2015 at 08:03AM

40
#844 - alex / @alexAngle8

08/23/2015 at 03:06PM

40
#845 - Dinesh Bhosale / @MrDineshBhosale

03/30/2016 at 07:57PM

40
#846 - Tom / @CronutFacts

05/21/2016 at 01:45AM

40
#847 - niels aamloos / @AamloosNiels

05/28/2016 at 01:10PM

40
#848 - Ryan van Rensburg / @rdvr001

07/21/2016 at 09:35AM

40
#849 - 赤佐田奈葉 / @akasatanaha_

06/26/2018 at 02:58AM

40
#850 - Diane Cochran / @DianeOfTheMoon

12/22/2018 at 09:57PM

40
#851 - Grant / @grant_7788

04/28/2019 at 02:42PM

40
#852 - vimgolfer24271 / @vimgolfer24271

05/13/2019 at 08:22AM

40
#853 - Chester Yap / @Chest_ErYap

07/27/2019 at 01:44PM

40
#854 - Baine Wedlock / @BaineWedlock

09/21/2019 at 02:34PM

40
#855 - vimgolfer / @vimgolfer7

10/04/2019 at 12:25AM

40
#856 - The Valencian Dev / @thevalenciandev

10/13/2020 at 12:30PM

40
#857 - neonunux / @neonunux

12/24/2020 at 12:55PM

40
#858 - Zach Lapidus / @zach_lapidus

05/24/2021 at 11:19PM

40
#859 - Year2Code / @Year2Code

06/16/2021 at 04:06PM

40
#860 - Chad Kennedy / @chadkennedyonli

07/12/2021 at 01:15AM

40
#861 - Michael Jaeger / @jaeger_mi

04/08/2022 at 03:20PM

40
#862 - grgrgrahklsbsmmmmmmm / @grgrgrmoom

08/31/2022 at 04:12AM

40
#863 - Janzen / @__Coos

09/15/2022 at 05:20AM

40
#864 - math is what I hate / @mpnmbn

10/26/2022 at 09:55AM

40
#865 - Lucas Monteiro / @lhtmonteiro

03/14/2023 at 05:54AM

40
#866 - idontlikeelonmusk / @idontlikee80799

08/01/2023 at 09:20PM

40
#867 - Jelani Felix / @Jelanife

02/03/2024 at 10:13PM

40
#868 - detachment1008 / @detachment1008

05/06/2024 at 10:09AM

40
#869 - Jayanth Koushik / @jayanthkoushik

07/09/2024 at 06:05AM

40
#870 - Henrik Lehtonen / @helehto

08/17/2024 at 11:14PM