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):
37
#571 - Miłosz Łakomy / @foobar01123

07/08/2019 at 09:41AM

37
#572 - Vladimir Leskov / @vladimirlesk

10/12/2019 at 12:01PM

37
#573 - BnnGolfer / @BnnGolfer

03/31/2020 at 06:49PM

37
#574 - Valdimar / @genkobar

06/08/2020 at 10:35PM

37
#575 - A A A / @37fatos

01/12/2021 at 02:23AM

37
#576 - july9793 / @july9793_

01/06/2022 at 12:33PM

37
#577 - yancy / @yancy_dong

04/29/2022 at 03:47AM

37
#578 - Qing Liu / @poeminlash

06/29/2022 at 02:22AM

37
#579 - Buatvimgolf / @buatvimgolf

07/28/2022 at 05:25AM

37
#580 - Bangash💉💉 / @DevotionGeo

10/08/2022 at 03:05AM

37
#581 - Youngchan Lee / @edwardycl

12/15/2022 at 07:05AM

37
#582 - Vgaccount645 / @vgaccount616132

05/10/2023 at 12:03AM

37
#583 - rayx / @ray-x

12/05/2023 at 11:37AM

37
#584 - 5S-MOHAMED-SHABAIK / @5S-MOHAMED-SHABAIK

01/12/2024 at 03:31PM

37
#585 - TheOdd / @TheOdd

02/03/2024 at 07:43PM

37
#586 - Ilya Shakirov / @aelaau

03/08/2024 at 12:05PM

37
#587 - arurusman / @I0pqOdjVGN5xYXa

05/05/2024 at 10:38AM

37
#588 - SanderHestvik / @SanderHestvik

06/09/2024 at 05:17PM

37
#589 - Ben Gadbois / @bengadbois

08/13/2024 at 09:55PM

37
#590 - Maximilian Ballard / @ediw8311xht

08/17/2024 at 12:02AM

37
#591 - Michael Cuffaro / @maiku1008

11/10/2024 at 09:10AM

37
#592 - Anton Savelyev / @PoiXP

01/02/2025 at 04:37PM

37
#593 - Daniel Reszka / @danielres

04/11/2025 at 07:03PM

38
#594 - Samus_ Michael / @gonna_hate

12/29/2010 at 02:40AM

38
#595 - Henri Bourcereau / @mmai

12/29/2010 at 11:41AM

38
#596 - Takayuki Tsukitani / @tsukkee

12/30/2010 at 07:27AM

38
#597 - Vincent Isambart / @vincentisambart

12/31/2010 at 01:14PM

38
#598 - wyl rof / @wylrof

01/02/2011 at 10:49AM

38
#599 - Brian Buckley / @bbuckley

01/20/2011 at 11:58AM

38
#600 - Grai / @haybeesea

02/16/2011 at 04:11AM