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):
46
#301 - Vojtěch Šívr / @VojtechSivr

06/09/2011 at 07:35PM

46
#302 - Arto Vuori / @dhpe

08/30/2012 at 09:33PM

46
#303 - Nick Bakkegaard / @Bakkemand

11/26/2012 at 01:25PM

46
#304 - Kuldeep Bora / @kuldeep_bora

04/21/2013 at 09:48AM

46
#305 - Felix Angerborn / @FelixAngerborn

09/20/2013 at 08:00PM

46
#306 - Oliver Christ / @0liverChrist

09/29/2013 at 06:47PM

46
#307 - LLiseil / @lliseil

07/15/2014 at 01:42PM

46
#308 - bratliff / @bratliff

08/10/2014 at 07:09AM

46
#309 - Patrick Pitoscia / @Patrick03960431

08/17/2014 at 02:48AM

46
#310 - Scott Atkins / @scottrick49

06/10/2021 at 01:59PM

46
#311 - John Xu / @xzzhiao

11/12/2021 at 03:45AM

47
#312 - Ryan Fitzgerald / @rwfitzge

12/29/2010 at 11:35AM

47
#313 - Alex B. / @SIGKILL

12/29/2010 at 01:30PM

47
#314 - Joe Hassick / @jhassick

12/29/2010 at 08:48PM

47
#315 - Ben Dowling / @coderholic

12/31/2010 at 08:30PM

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

01/07/2011 at 08:53PM

47
#317 - ae7o / @ae7o

04/29/2011 at 09:30PM

47
#318 - Øystein Walle / @oysteinwalle

07/12/2011 at 03:25PM

47
#319 - Tj / @yrddy

08/19/2014 at 10:38AM

47
#320 - Darkhan / @d4rkh4n

02/03/2016 at 10:39AM

47
#321 - lzh / @ly_zhng

06/14/2020 at 05:57PM

47
#322 - A White Dwarf / @AWhiteDwarf1

06/29/2021 at 03:37AM

47
#323 - aravindthangavel / @aravindpt

04/15/2022 at 04:50PM

47
#324 - anakojm / @anakojm

07/14/2022 at 01:47AM

47
#325 - jimmarq / @jimmarq

11/01/2022 at 07:04PM

47
#326 - bonettimrc / @bonettimrc

04/28/2024 at 02:05PM

48
#327 - Daniel Dourvaris / @dourvaris

12/29/2010 at 02:08PM

48
#328 - Abhinav Gupta / @ag90

12/29/2010 at 03:02PM

48
#329 - Aaron Bull Schaefer / @elasticdog

12/29/2010 at 04:23PM

48
#330 - Andrew McDonough / @andrewmcdonough

12/29/2010 at 06:32PM