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

319 active golfers, 832 entries

Leaderboard (lowest score wins):
44
#211 - Andrew Michaud / @andrewjmichaud

09/04/2015 at 07:48PM

44
#212 - Gerald Tilma / @GeraldTilma

10/22/2015 at 02:12AM

44
#213 - Ryan Marcotte / @ryanjmarcotte

11/16/2015 at 02:53PM

44
#214 - Daniel / @Daniel00288663

03/31/2017 at 10:09AM

44
#215 - Sam Hammer / @samhammer325

05/07/2017 at 03:46AM

44
#216 - Daniel de Vries / @devries_d

02/08/2018 at 04:53PM

44
#217 - Marius Jurgelenas / @MarenasLT

07/12/2018 at 12:50PM

44
#218 - Jurica / @Jurica34581259

11/19/2018 at 09:40PM

45
#219 - Matthew Draper / @_matthewd

12/29/2010 at 12:28PM

45
#220 - Lasse Immonen / @turtleman10

12/29/2010 at 01:00PM

45
#221 - Robert Leland / @robleland

12/29/2010 at 01:23PM

45
#222 - Mariano Guerra / @marianoguerra

12/29/2010 at 01:31PM

45
#223 - johnny / @johnnychm

12/29/2010 at 01:38PM

45
#224 - Dave V. / @dave_v

12/29/2010 at 01:45PM

45
#225 - Sérgio Figueiredo / @doubl3dge

12/29/2010 at 04:46PM

45
#226 - Ben Lenarts / @benlenarts

12/29/2010 at 06:45PM

45
#227 - sirex / @sirex

12/29/2010 at 09:23PM

45
#228 - lionel young / @lionelyoung

12/30/2010 at 04:51AM

45
#229 - Pierre / @Pihour

12/30/2010 at 06:27AM

45
#230 - David Shaw / @shawthings

12/30/2010 at 09:53AM

45
#231 - Behnam Esfahbod / @zwnj

12/30/2010 at 12:38PM

45
#232 - Joshua Flanagan / @jflanagan

01/01/2011 at 04:02PM

45
#233 - Asmund / @herrasbe

01/02/2011 at 06:30AM

45
#234 - Prody / @Prody225

01/02/2011 at 07:19PM

45
#235 - Pawka / @Pawka

01/16/2011 at 11:44AM

45
#236 - Julien Pivotto / @roidelapluie

03/17/2011 at 09:24PM

45
#237 - Ilya Strukov / @i1ey

05/02/2011 at 06:13AM

45
#238 - Dario Cazzaro / @darioqa

09/18/2011 at 10:39PM

45
#239 - Dj Vimgolf / @dj_vimgolf

01/01/2012 at 04:04PM

45
#240 - Golf Sinteppadon / @minigolf2000

04/27/2012 at 12:06AM