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):
68
#1681 - lionel young / @lionelyoung

12/29/2010 at 12:44AM

68
#1682 - Ilya Grigorik / @igrigorik

12/31/2010 at 08:07PM

68
#1683 - Alan Kessler / @alankesslr

12/11/2012 at 09:04PM

68
#1684 - ryk / @rykarn

03/29/2014 at 01:11PM

68
#1685 - kafang plays vimgolf / @KafangV

12/17/2020 at 07:06AM

68
#1686 - Surya Balakrishnan / @surya_bdev

10/07/2022 at 02:49PM

68
#1687 - Ishmael Riles / @isho

01/14/2025 at 08:38PM

68
#1688 - Chen / @chenstanilovsky

02/05/2025 at 02:07AM

68
#1689 - Holger / @holgern

03/14/2025 at 01:33PM

69
#1690 - Yu-Hsuan Li / @Walker_tw

12/21/2011 at 07:11AM

69
#1691 - chldbstj4536 / @chldbstj4536

05/19/2024 at 08:36AM

69
#1692 - Willy / @Willy6932612311

09/05/2024 at 08:52PM

70
#1693 - david / @ultrayoshi

12/31/2010 at 07:51PM

70
#1694 - Mike Korcynski / @mkorcy

02/04/2012 at 01:08AM

70
#1695 - Ryan Abbott / @ThinkMoveBe

08/24/2012 at 05:21AM

70
#1696 - Saxon Unrue / @joeunrue

11/09/2012 at 01:56PM

70
#1697 - Dave Brda / @BrdaDave

11/01/2018 at 02:25PM

70
#1698 - 김동철 / @gimdong01525533

04/15/2024 at 04:30AM

70
#1699 - 🥚 / @schmarles_

09/19/2024 at 09:28PM

71
#1700 - Dan Quellhorst / @quellhorst

12/28/2010 at 09:59PM

71
#1701 - Михаил Минков / @_x10

08/26/2011 at 10:14AM

71
#1702 - Aaron Snoswell / @aaronsnoswell

09/24/2012 at 03:14PM

71
#1703 - Rtest / @Rtest40568165

11/16/2022 at 03:20PM

71
#1704 - Ratkovszki István / @RatkovszkiIstvn

11/26/2022 at 02:58PM

72
#1705 - radamant / @radamant

12/28/2010 at 09:34PM

72
#1706 - Phil Webster / @philwebster

03/09/2013 at 02:22AM

72
#1707 - Даня Ефимов / @Abberatus

09/04/2022 at 08:41PM

72
#1708 - Sandy1796ii / @Sandy1796ii

10/19/2024 at 05:21AM

73
#1709 - fdsfasdf / @fdsfasdf1

12/14/2011 at 08:13PM

73
#1710 - king sized toilet / @ohwowcrazy

06/30/2014 at 08:50PM