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 4d1b1b97c58eaa2a8a0002fc

Python Hello World! Reformatting

A novice Python using prints Hello World! and a pro shows him different way. Using vim to get into pro style from novice, win the challenge.

Start file
#!/usr/bin/python
import sys
a
= "Hello World!"
sys
.stdout.write(str(a[0]))
sys
.stdout.write(str(a[1]))
sys
.stdout.write(str(a[2]))
sys
.stdout.write(str(a[3]))
sys
.stdout.write(str(a[4]))
sys
.stdout.write(str(a[5]))
sys
.stdout.write(str(a[6]))
sys
.stdout.write(str(a[7]))
sys
.stdout.write(str(a[8]))
sys
.stdout.write(str(a[9]))
sys
.stdout.write(str(a[10]))
sys
.stdout.write(str(a[11]))
End file
#!/usr/bin/python
import sys
a
= "Hello World!"
for i in range(0, len(a)):
  sys
.stdout.write(str(a[i]))

View Diff

4,15c4,5
< sys.stdout.write(str(a[0]))
< sys.stdout.write(str(a[1]))
< sys.stdout.write(str(a[2]))
< sys.stdout.write(str(a[3]))
< sys.stdout.write(str(a[4]))
< sys.stdout.write(str(a[5]))
< sys.stdout.write(str(a[6]))
< sys.stdout.write(str(a[7]))
< sys.stdout.write(str(a[8]))
< sys.stdout.write(str(a[9]))
< sys.stdout.write(str(a[10]))
< sys.stdout.write(str(a[11]))
---
> for i in range(0, len(a)):
>   sys.stdout.write(str(a[i]))

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 381 remaining solutions by signing in and submitting your own entry
#382 Zhao Yao / @Lynch8080 - Score: 93 - 12/31/10 @ 17:33
jjj12ddofor i in range()<Esc>i0, len()<Esc>ia<Esc>$a:<CR><BS>  sysy<BS>.stu<BS>dout.write()<Esc>istr()<Esc>ia[]<Esc>ii<Esc>:wq<CR>

0 comments


Created by: @Ujjwol

382 active golfers, 1000 entries

Leaderboard (lowest score wins):
43
#181 - jj johnson / @jcassj1

08/23/2016 at 01:14PM

43
#182 - Michał Dytko / @DytkoM

12/28/2016 at 01:55PM

43
#183 - Gurukandhamoorthi / @Gurukandhamoor1

07/15/2017 at 04:35PM

43
#184 - Adrian Staniec / @adrianstaniec

08/06/2017 at 05:58PM

43
#185 - xyz / @menhej

02/04/2018 at 01:06AM

43
#186 - Martynas Bardauskas / @mbardauskas

07/12/2018 at 12:47PM

43
#187 - alekfed / @alek_fed

04/16/2019 at 02:24PM

43
#188 - Aioriya / @AioriyaDonk

09/12/2019 at 11:05PM

43
#189 - mevmev / @mevmev8

11/28/2020 at 02:11AM

43
#190 - Patrick Martin / @PatrickDMartin

07/05/2021 at 06:38PM

43
#191 - july9793 / @july9793_

01/06/2022 at 02:42PM

43
#192 - rappenstein2 / @rappenstein2

01/20/2022 at 04:53PM

43
#193 - blabla zincou / @BZincou

03/06/2022 at 08:52PM

43
#194 - Hugh / @deeoh22

12/12/2022 at 03:57PM

43
#195 - jackyhevey / @jackyhevey

03/01/2024 at 04:46PM

43
#196 - Justin Choi / @Mcthecuber

07/01/2024 at 07:04PM

43
#197 - Alex Khakhlyuk / @khakhlyuk

08/22/2024 at 08:18PM

44
#198 -  Ikhsan Maulana / @ixandidu

12/29/2010 at 11:56AM

44
#199 - uuu / @uu59

12/29/2010 at 07:01PM

44
#200 - Ankit Shankar / @thelastnode

12/29/2010 at 07:45PM

44
#201 - nooodl / @nooodl

12/30/2010 at 11:05AM

44
#202 - PA Parent / @paparent

12/30/2010 at 01:08PM

44
#203 - solsTiCe d'Hiver / @solstice_dhiver

12/30/2010 at 05:28PM

44
#204 - Cap / @cappy_haddock

12/30/2010 at 07:38PM

44
#205 - Leeward Bound / @leewardbound

12/31/2010 at 03:48PM

44
#206 - Casey W Crites / @caseycrites

01/01/2011 at 07:04AM

44
#207 - Ben Brown / @benofbrown

01/01/2011 at 07:28PM

44
#208 - Israel Chauca F. / @Raimondi

01/01/2011 at 08:59PM

44
#209 - Brad / @bjjwillis

01/02/2011 at 11:54AM

44
#210 - Olivier Verdier / @OlivierVerdier

01/03/2011 at 04:48PM