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

1791 active golfers, 7259 entries

Leaderboard (lowest score wins):
42
#1021 - Magnus von Wachenfeldt / @brutusmcforce

05/16/2022 at 07:31PM

42
#1022 - James Elson / @JamesElson_RL

09/19/2022 at 03:52PM

42
#1023 - xiang / @xiang56002997

08/29/2023 at 11:04PM

42
#1024 - BlockLune / @BlockLune

01/08/2024 at 04:54AM

42
#1025 - 5S-BENDEGUZ-HORVATH / @5S-BENDEGUZ-HORVATH

01/12/2024 at 03:18PM

42
#1026 - John Hong / @jhong97

03/22/2024 at 03:34AM

42
#1027 - kbrashem / @kbrashem

05/14/2024 at 04:08AM

42
#1028 - cotarmanach / @cotarmanach

05/27/2024 at 09:15PM

42
#1029 - Goran Petrovity / @5S-Goran

08/08/2024 at 04:14PM

42
#1030 - jfdg01 / @jfdg01

10/19/2024 at 02:14PM

42
#1031 - Elliot Schemmel / @regulated

10/29/2024 at 09:53PM

42
#1032 - Chadbourne Smith / @burlingsmith

05/26/2025 at 06:01PM

43
#1033 - Samuel Mullen / @samullen

12/28/2010 at 07:52PM

43
#1034 - Dan Callahan / @callahad

12/28/2010 at 09:12PM

43
#1035 - Gary Rennie / @TheGazler

08/03/2011 at 03:04PM

43
#1036 - Shannon / @shannonskipper

11/29/2011 at 09:51AM

43
#1037 - Michael Levin / @kinnetica

12/06/2011 at 05:19PM

43
#1038 - Stephen Jennings / @sgjennings

02/02/2012 at 07:32AM

43
#1039 - Manu / @bound_test

02/13/2012 at 09:16AM

43
#1040 - Steven Sloss / @StevenSloss

02/16/2012 at 03:40PM

43
#1041 - Peter Schlette / @pschlette

08/01/2012 at 04:40AM

43
#1042 - Thiago Tasca Nunes / @ttascanunes

11/08/2012 at 05:54PM

43
#1043 - Maksim S. / @waynesayonara

07/18/2013 at 07:17PM

43
#1044 - Joel Taylor / @joelteon_

07/23/2013 at 02:09AM

43
#1045 - Dan Harrington / @Dan1H1

08/13/2013 at 01:30AM

43
#1046 - adi li / @guessimtoolate

08/14/2013 at 05:45PM

43
#1047 - Kevin Etienne / @42__kevin

08/18/2013 at 06:45PM

43
#1048 - Kostyantyn Leschenko / @settler_kos

08/19/2013 at 08:01AM

43
#1049 - Tony Han / @tony612_han

08/31/2013 at 05:31AM

43
#1050 - John Gray Cole / @johngraycole

12/08/2013 at 07:49PM