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):
73
#1711 - king sized toilet / @ohwowcrazy

06/30/2014 at 08:50PM

73
#1712 - sean choi / @joosting

06/04/2021 at 08:59AM

73
#1713 - Alex Elarbee / @elarbee

09/23/2024 at 12:57AM

74
#1714 - Jianfeng / @Jianfen22425058

01/28/2021 at 01:24PM

74
#1715 - Simon Carrignon / @SimonCarrignon

12/01/2022 at 04:57PM

75
#1716 - Toader Mihai Claudiu / @mtoader

12/31/2010 at 11:55AM

75
#1717 - Aaron / @_Lordofthevoid_

11/28/2019 at 02:27PM

75
#1718 - Maurice Schmicking / @m_schmicking

03/25/2023 at 10:28PM

76
#1719 - ishmaelahmed / @ishmaelahmed

12/30/2010 at 09:02PM

76
#1720 - Delwyn de Villiers / @delwynd

05/04/2011 at 12:26PM

76
#1721 - Robert Höglund / @rhoglund

07/16/2012 at 03:58PM

76
#1722 - Almog / @almog

01/28/2014 at 01:45PM

77
#1723 - Ben Friedland / @bfriedland174

07/10/2013 at 11:00PM

77
#1724 - Mohit Sharma / @m0hitsharma

12/30/2013 at 02:59AM

77
#1725 - Juan Aguero / @juansta

02/03/2014 at 04:13AM

77
#1726 - Kevin Cooler / @KevinCooler

08/10/2018 at 04:49PM

78
#1727 - kunihiko ito / @kunitoo

04/25/2013 at 12:20PM

78
#1728 - Shunichi Kanade / @shunkana

11/04/2018 at 01:32AM

78
#1729 - sbokupripeku / @sbokupripeku

05/28/2021 at 03:26PM

78
#1730 - Hyungyong Kim / @yong27

10/05/2023 at 04:42AM

79
#1731 - Luc Stepniewski / @lstep

12/29/2010 at 02:43PM

79
#1732 - Lee Jones / @scribblethink

09/27/2011 at 02:15PM

79
#1733 - Etrama / @Etrama

02/24/2025 at 03:14AM

80
#1734 - Nanne / @Whazor

12/28/2010 at 10:19PM

80
#1735 - speedking456 / @speedking456

07/11/2025 at 06:51AM

81
#1736 - Rap Game Dan Aykroyd / @rapdanaykroyd

02/02/2012 at 06:44PM

82
#1737 - Ed Gibbs / @edward_gibbs

08/01/2011 at 02:23PM

82
#1738 - Ayman Farhat / @aymanfarhat

06/03/2015 at 12:05PM

84
#1739 - 5S-NORA-RAB / @5S-NORA-RAB

08/22/2024 at 11:21AM

85
#1740 - Peter Esselius / @esselius

02/19/2013 at 04:20PM