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):
41
#61 - Ben Hill / @KaizenSoze70

10/13/2017 at 12:38PM

41
#62 - c0llision / @sh3llcode

01/28/2018 at 10:18AM

41
#63 - Arijus / @argshook

07/12/2018 at 12:51PM

41
#64 - Dax / @zacoxi

12/07/2018 at 05:25AM

42
#65 - kana / @kana1

12/29/2010 at 11:58AM

42
#66 - Fer Enaf / @0x00C0FFEE

12/29/2010 at 12:04PM

42
#67 - Tom Adams / @holizz

12/29/2010 at 01:03PM

42
#68 - Per Johansson / @oszau

12/29/2010 at 01:56PM

42
#69 - Rodolphe Marques / @rodmar_

12/29/2010 at 04:36PM

42
#70 - space for rent / @raf_whispering

12/29/2010 at 05:16PM

42
#71 - Addisu Taddese / @azeey

12/29/2010 at 07:15PM

42
#72 - kuhout / @kuhout

12/29/2010 at 08:32PM

42
#73 - Jordan Lewis / @JordanALewis

12/30/2010 at 01:23AM

42
#74 - Ed Singleton / @Singletoned

12/30/2010 at 12:16PM

42
#75 - Denis Odorcic / @denisodorcic

12/30/2010 at 06:57PM

42
#76 - Richard Sanchez / @vimlearner

12/31/2010 at 01:07PM

42
#77 - Vincent Isambart / @vincentisambart

01/01/2011 at 03:51AM

42
#78 - Josh Weinberg / @jcweinberg

01/01/2011 at 06:17PM

42
#79 - Ricardo Mendes / @locks

01/01/2011 at 06:32PM

42
#80 - derp derp / @derp__

01/01/2011 at 11:38PM

42
#81 - Peter Anselmo / @peter_anselmo

01/02/2011 at 07:28PM

42
#82 - rabidpraxis / @rabidpraxis

01/02/2011 at 11:25PM

42
#83 - Gael / @darkael2

01/06/2011 at 11:53PM

42
#84 - Tim Chase / @gumnos

01/09/2011 at 03:05AM

42
#85 - Pete Johns / @johnsyweb

01/12/2011 at 08:58PM

42
#86 - h_east (トロッコ6個) / @h_east

01/16/2011 at 07:42AM

42
#87 - justin / @j10

01/17/2011 at 07:24AM

42
#88 - Oleg Roshupkin / @jjjahson

01/21/2011 at 07:38PM

42
#89 - Joost / @vlabakje

02/14/2011 at 09:00AM

42
#90 - vg / @vimgolfer

02/26/2011 at 04:51PM