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):
41
#931 - Evgeny`s Kindle / @EvgenyKindle

04/24/2018 at 10:06AM

41
#932 - Rakesh P / @rakeshpgopal

05/23/2018 at 06:03PM

41
#933 - Kris Ezra / @kris_ezra

09/12/2018 at 03:39AM

41
#934 - Dryvnt / @Dryvnt

04/04/2019 at 01:20PM

41
#935 - Simon Zeng / @KronicMan

06/15/2019 at 05:01PM

41
#936 - Iggy / @iggredible

10/24/2019 at 02:51AM

41
#937 - Lory / @Lory46845742

11/08/2019 at 08:36AM

41
#938 - Matt Aschmann / @ma7hatter

12/30/2019 at 06:44PM

41
#939 - Karnival K / @K4rnival

01/15/2020 at 07:16PM

41
#940 - Jason Neylon / @jasonneylon

01/18/2020 at 01:43PM

41
#941 - Jason / @roosjason

04/25/2020 at 11:08AM

41
#942 - Jeff Cui / @jeffacce

05/13/2020 at 10:35AM

41
#943 - Pham Tuan Anh / @anhpt379

06/28/2020 at 09:12PM

41
#944 - pherapont / @pherapont1

12/21/2020 at 07:59AM

41
#945 - josh / @_zvjos

06/17/2022 at 01:28AM

41
#946 - (ノ◕ヮ◕)ノ*:・゚✧ / @Mebazaa

07/01/2022 at 04:28PM

41
#947 - coffee-addict / @ccoffee_addictt

11/21/2022 at 09:39PM

41
#948 - MC / @MC88686523

12/01/2022 at 02:11PM

41
#949 - fufuror / @futachima

01/25/2023 at 03:28PM

41
#950 - Oisin Ward / @OisinWard_vg

07/05/2023 at 12:40PM

41
#951 - menb / @menb111

06/22/2024 at 08:01PM

41
#952 - 정준태 / @Powering111

06/24/2024 at 02:00AM

41
#953 - 赵坤 / @artzok

06/24/2024 at 04:54AM

41
#954 - Marcos Almeida / @maurelio1234

07/20/2024 at 07:50PM

41
#955 - Eran / @RedSponge

11/07/2024 at 09:45PM

41
#956 - Leon Kacowicz / @leonkacowicz

05/04/2025 at 11:54AM

41
#957 - Egor Derevlev / @Neofuturist

06/15/2025 at 11:10PM

42
#958 - Dmytro Shteflyuk / @kpumuk

12/29/2010 at 03:57PM

42
#959 - Jarkko Laine / @jarkko

12/29/2010 at 07:18PM

42
#960 - emmanuel delgado / @chischaschos

01/03/2011 at 12:37AM