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):
53
#1501 - jestem króliczkiem / @karlicoss

08/05/2018 at 02:50PM

53
#1502 - JulianW / @JulianWgs

11/03/2018 at 12:28PM

53
#1503 - Vim Golfer / @VimGolfer6

08/07/2019 at 01:02PM

53
#1504 - 路磨平 / @lumoping

01/25/2024 at 07:39AM

53
#1505 - azu0nyan / @azu0nyan

05/16/2024 at 06:57PM

53
#1506 - tncargil / @tncargil

08/25/2024 at 03:35PM

53
#1507 - Christensen, Scott (S.C.) / @MCHRI120_ford

11/03/2024 at 08:42PM

53
#1508 - akashcapitalnumbers / @akashcapitalnumbers

12/25/2024 at 12:02PM

53
#1509 - KeshSridhar / @KeshSridhar

03/04/2025 at 01:55PM

53
#1510 - Alex Lewin / @_AlexLewin

04/24/2025 at 12:07AM

54
#1511 - Nicolás Sanguinetti / @godfoca

12/28/2010 at 07:59PM

54
#1512 - conor / @omgconor

01/22/2011 at 12:07AM

54
#1513 - Levon Lloyd / @levonlloyd

02/04/2011 at 02:39PM

54
#1514 - Fletcher Nichol / @fnichol

03/21/2011 at 03:56AM

54
#1515 - Tof / @Tof23

06/17/2011 at 04:59AM

54
#1516 - cameron / @cameronaustgen

09/04/2011 at 08:50AM

54
#1517 - Rafael França / @rafaelfranca

09/27/2011 at 09:26PM

54
#1518 - kyriacos / @kyriacos

12/12/2011 at 04:15PM

54
#1519 - Casper Christensen / @Casper__C

12/04/2013 at 08:27PM

54
#1520 - Andrew Loucky / @merely_oolong

03/24/2014 at 11:21PM

54
#1521 - Samir Sadek / @netsamir

07/21/2015 at 05:52AM

54
#1522 - Conor Ryan / @conorjryan

11/18/2015 at 09:16AM

54
#1523 - Matt Walsh / @wattmalsh

02/06/2017 at 10:42PM

54
#1524 - Netznarkose / @netznarkose

07/27/2017 at 09:21PM

54
#1525 - Justin Hoyt / @JustinHoyt24

06/23/2018 at 05:17PM

54
#1526 - Michael V. / @mvivirito

06/16/2020 at 12:12AM

54
#1527 - 김범준 / @kmbmjn

01/14/2021 at 05:28AM

54
#1528 - rdabrunk / @rdabrunk

11/06/2024 at 07:19PM

54
#1529 - Oleksii Sanin / @AlexSanin

12/04/2024 at 04:39PM

54
#1530 - Marcio Junior / @marcioj

12/17/2024 at 12:40AM