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):
50
#1411 - Ryan Knowles / @RyKnowl

11/17/2012 at 01:28AM

50
#1412 - HongKilDong / @HongKilDong

03/12/2013 at 12:44PM

50
#1413 - Vincent Lee / @vincentleest

07/04/2013 at 07:00AM

50
#1414 - David Pathakjee / @DavidPathakjee

08/14/2013 at 03:47AM

50
#1415 - Peder Sørensen / @pedersorensen86

08/23/2013 at 10:18AM

50
#1416 - yoohey / @yoohey_m

10/22/2013 at 12:16PM

50
#1417 - Raphael / @rnstlr

11/24/2013 at 04:17PM

50
#1418 - Aurélien Vallée / @aurelienvallee

02/04/2014 at 11:58AM

50
#1419 - Jeff / @sir_wiggles3

09/09/2018 at 02:51AM

50
#1420 - Maas Lalani / @maaslalani

12/07/2018 at 03:18AM

50
#1421 - fucus / @fishlovebanana

03/21/2019 at 07:02AM

50
#1422 - Laura Skillington / @lauraskills1

12/17/2020 at 10:02PM

50
#1423 - Babil G. Sarwar / @gsbabil

08/07/2021 at 08:31PM

50
#1424 - e1mnos / @e1mnos

08/10/2021 at 04:06PM

50
#1425 - russellzhaomao / @russellzhaomao

05/21/2022 at 11:46PM

50
#1426 - alexeypetrenko / @alexeypetrenko

06/27/2024 at 12:40PM

50
#1427 - Julien Khlaut / @SovanKhlt

01/26/2025 at 02:44PM

50
#1428 - e.cousinet / @ecousinet

02/14/2025 at 03:58PM

51
#1429 - Pierre / @Pihour

12/30/2010 at 07:44PM

51
#1430 - neleai / @enlaei

12/31/2010 at 10:50PM

51
#1431 - Ben Hall / @Ben_Hall

01/03/2011 at 01:45PM

51
#1432 - Jamie Mill / @jamiemill

12/14/2011 at 09:08PM

51
#1433 - Ben Wagaman / @jamin4jc

01/13/2012 at 04:23PM

51
#1434 - Julian / @ShumpEvenwood

11/25/2012 at 04:43PM

51
#1435 - Adam Bell / @adamgbell

02/13/2013 at 06:00PM

51
#1436 - Stephen Tindall / @stindall77

02/21/2013 at 06:02PM

51
#1437 - Ian Oxley / @ianoxley

10/23/2013 at 12:45PM

51
#1438 - adamblank / @adamblank

12/20/2013 at 07:42PM

51
#1439 - Caleb Perkins / @tollbooth

01/29/2014 at 07:38AM

51
#1440 - Marcin Cabaj / @marcincabaj

02/06/2014 at 01:59PM