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):
41
#61 - sockdude1 / @sockdude1

11/05/2013 at 06:59AM

41
#62 - Pandu / @pandu_golf

01/05/2014 at 09:48AM

41
#63 - pikaren / @REALpikaren

01/12/2014 at 08:31AM

41
#64 - Joonas Pihlajamaa / @jokkebk

02/19/2014 at 02:59PM

41
#65 - ZorgroZ / @ZorgroZ

04/14/2014 at 09:52PM

41
#66 - kimber gonzalez / @kimberlycreates

01/21/2015 at 03:28PM

41
#67 - Dimitar Dimitrov / @kurkale6ka

03/22/2016 at 12:08PM

41
#68 - ramandeep randhawa / @rsrandhawa

04/11/2016 at 03:42AM

41
#69 - niels aamloos / @AamloosNiels

05/28/2016 at 03:08PM

41
#70 - Bill Ruddock / @biinari

10/25/2016 at 03:26PM

41
#71 - Reinaldo Astudillo / @astudillor

03/26/2017 at 11:37AM

41
#72 - Brandon Height / @Lask0x

08/09/2017 at 08:52PM

41
#73 - Darren Weston / @dazWestonUK

09/02/2017 at 01:18PM

41
#74 - Ben Hill / @KaizenSoze70

10/13/2017 at 12:38PM

41
#75 - c0llision / @sh3llcode

01/28/2018 at 10:18AM

41
#76 - Arijus / @argshook

07/12/2018 at 12:51PM

41
#77 - Dax / @zacoxi

12/07/2018 at 05:25AM

42
#78 - kana / @kana1

12/29/2010 at 11:58AM

42
#79 - Fer Enaf / @0x00C0FFEE

12/29/2010 at 12:04PM

42
#80 - Tom Adams / @holizz

12/29/2010 at 01:03PM

42
#81 - Per Johansson / @oszau

12/29/2010 at 01:56PM

42
#82 - Rodolphe Marques / @rodmar_

12/29/2010 at 04:36PM

42
#83 - space for rent / @raf_whispering

12/29/2010 at 05:16PM

42
#84 - Addisu Taddese / @azeey

12/29/2010 at 07:15PM

42
#85 - kuhout / @kuhout

12/29/2010 at 08:32PM

42
#86 - Jordan Lewis / @JordanALewis

12/30/2010 at 01:23AM

42
#87 - Ed Singleton / @Singletoned

12/30/2010 at 12:16PM

42
#88 - Denis Odorcic / @denisodorcic

12/30/2010 at 06:57PM

42
#89 - Richard Sanchez / @vimlearner

12/31/2010 at 01:07PM

42
#90 - Vincent Isambart / @vincentisambart

01/01/2011 at 03:51AM