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):
49
#1381 - George GZ Zakhour / @AlloGeorge

06/25/2013 at 08:01AM

49
#1382 - Felipe Jaramillo F / @mrfelipe

04/01/2014 at 06:25PM

49
#1383 - Hieu M. Nguyen / @ngnmhieu

08/15/2014 at 11:35PM

49
#1384 - Malte R / @maltoe

11/30/2014 at 02:47PM

49
#1385 - Jordana Lachow / @TomofBedlam

01/06/2015 at 04:10PM

49
#1386 - ipson_nek / @ipson_nek

04/03/2015 at 06:36PM

49
#1387 - Kirill Sidenko / @KirillSidenko

06/19/2016 at 12:13PM

49
#1388 - Charlie OConor / @charlieoconor

10/30/2017 at 04:53PM

49
#1389 - faisal / @faisalhackshah

11/25/2018 at 03:28AM

49
#1390 - abhijeet patil / @abhijeetptl5

09/02/2020 at 09:09PM

49
#1391 - タケ / @Take3832

04/25/2022 at 10:13AM

49
#1392 - gotovimpro / @gotovimpro1

09/16/2022 at 03:32PM

49
#1393 - Bas / @m1tix

09/23/2022 at 02:24PM

49
#1394 - jimmarq / @jimmarq

11/01/2022 at 04:04PM

49
#1395 - Adigan / @Addigan

05/13/2023 at 10:59AM

49
#1396 - Riccardo Gherardi / @r1cc4rd0_g

09/27/2023 at 12:03AM

49
#1397 - Daan Manneke / @DaanManneke

10/24/2023 at 03:56PM

49
#1398 - Jeff Arese / @jeffarese

05/27/2024 at 06:51AM

49
#1399 - Justin Choi / @Mcthecuber

07/01/2024 at 06:26PM

49
#1400 - KhaAdam / @KhaAdam

08/08/2024 at 08:23AM

49
#1401 - shenyfg / @shenyfg

08/28/2024 at 07:08AM

49
#1402 - Fionn Fitzmaurice / @fionn

12/25/2024 at 04:10PM

50
#1403 - Jordan Lewis / @JordanALewis

12/30/2010 at 06:47PM

50
#1404 - Oleg Pestov / @opestov

03/14/2011 at 06:19PM

50
#1405 - Unreal Name / @morphles

06/02/2011 at 11:06AM

50
#1406 - approaching236 / @approaching236

06/22/2011 at 11:49PM

50
#1407 - Josh / @beau_jo

08/01/2011 at 07:55PM

50
#1408 - den野郎 / @asihuretti

01/07/2012 at 05:00AM

50
#1409 - Thomas Pfeiffer / @pfeiffdrauf

02/29/2012 at 04:05PM

50
#1410 - levicook / @levicook

03/28/2012 at 07:27PM