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 314 remaining solutions by signing in and submitting your own entry
#315 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

315 active golfers, 825 entries

Leaderboard (lowest score wins):
45
#241 - foo / @foo88832727

10/18/2013 at 06:06PM

45
#242 - Bjorn / @bjorn_248

11/15/2013 at 08:04PM

45
#243 - Marcus Kellerman / @sharkusk

03/30/2014 at 07:43AM

45
#244 - d c / @chikenwaffle

07/12/2014 at 04:40AM

45
#245 - かしゅーなっつ@修行中 / @kashew_nuts

08/02/2014 at 06:56AM

46
#246 - Gautier / @Gowtier

12/29/2010 at 12:31PM

46
#247 - Ray / @zer01ne

12/30/2010 at 10:34PM

46
#248 - Yannick LM / @yanicklm

12/30/2010 at 11:11PM

46
#249 - Guillaume Bonnoron / @gbonnoron

12/31/2010 at 11:38AM

46
#250 - Carl Friedrich Bolz / @cfbolz

01/04/2011 at 11:10PM

46
#251 - Thom Hughes / @thom_hughes_1

03/28/2011 at 08:54AM

46
#252 - Vojtěch Šívr / @VojtechSivr

06/09/2011 at 07:35PM

46
#253 - Arto Vuori / @dhpe

08/30/2012 at 09:33PM

46
#254 - Nick Bakkegaard / @Bakkemand

11/26/2012 at 01:25PM

46
#255 - Kuldeep Bora / @kuldeep_bora

04/21/2013 at 09:48AM

46
#256 - Felix Angerborn / @FelixAngerborn

09/20/2013 at 08:00PM

46
#257 - Oliver Christ / @0liverChrist

09/29/2013 at 06:47PM

46
#258 - LLiseil / @lliseil

07/15/2014 at 01:42PM

46
#259 - bratliff / @bratliff

08/10/2014 at 07:09AM

46
#260 - Patrick Pitoscia / @Patrick03960431

08/17/2014 at 02:48AM

47
#261 - Ryan Fitzgerald / @rwfitzge

12/29/2010 at 11:35AM

47
#262 - Alex B. / @SIGKILL

12/29/2010 at 01:30PM

47
#263 - Joe Hassick / @jhassick

12/29/2010 at 08:48PM

47
#264 - Ben Dowling / @coderholic

12/31/2010 at 08:30PM

47
#265 - R. P. Fainmen / @4loops

01/07/2011 at 08:53PM

47
#266 - ae7o / @ae7o

04/29/2011 at 09:30PM

47
#267 - Øystein Walle / @oysteinwalle

07/12/2011 at 03:25PM

47
#268 - Tj / @yrddy

08/19/2014 at 10:38AM

47
#269 - Darkhan / @d4rkh4n

02/03/2016 at 10:39AM

48
#270 - Daniel Dourvaris / @dourvaris

12/29/2010 at 02:08PM