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

402 active golfers, 1057 entries

Leaderboard (lowest score wins):
49
#361 - Stephen Gordon / @DubsGordon

08/01/2011 at 11:28PM

49
#362 - Aaron Josephs / @aaronjosephs1

05/02/2013 at 02:18AM

49
#363 - Sebastian / @dersharky

05/12/2020 at 08:21PM

49
#364 - Olivier Bégassat / @zk_evm

05/27/2023 at 05:19PM

49
#365 - Luke M / @lukemv

06/15/2024 at 01:51AM

49
#366 - Vechyaslav Zalupenko / @iouwoiiqw

10/10/2026 at 11:00AM

50
#367 - Aleksander Balicki / @alekbalicki

12/29/2010 at 02:11PM

50
#368 - Dezső Zoltán / @zakiazigazi

12/29/2010 at 04:04PM

50
#369 - Jack Kordas / @JackKordas

12/29/2010 at 04:08PM

50
#370 - Alain Gilbert / @alain_gilbert

12/30/2010 at 06:09AM

50
#371 - Diwakar Singh Parmar / @parmardiwakar150

08/27/2024 at 12:56PM

51
#372 - Linus G Thiel / @yesbabyyes

12/29/2010 at 01:55PM

51
#373 - Boris Barroso / @borisb

12/29/2010 at 07:27PM

51
#374 - cracoucax / @cracoucax

12/30/2010 at 11:00AM

51
#375 - Su. / @0moMi

12/31/2010 at 12:16AM

51
#376 - RobertT / @techrt2050

09/22/2013 at 05:18AM

51
#377 - Benjamin Kiefer / @bkiefs

04/18/2019 at 08:53PM

52
#378 - Nacho Barrientos / @nachobarrientos

12/29/2010 at 12:25PM

52
#379 - Knaughty / @Kn4ughty

08/27/2024 at 02:51AM

53
#380 - Chris Faulkner / @bookdarts

12/29/2010 at 12:34PM

53
#381 - Jan Kassens / @kassens

12/29/2010 at 03:30PM

53
#382 - Thibault Jouan / @tjouan

12/29/2010 at 10:17PM

53
#383 - Jean-Charles Quillet / @jc_jecaro

05/19/2020 at 03:30PM

54
#384 - Kishyr Ramdial / @kishyr

12/29/2010 at 03:44PM

54
#385 - Juan C. Muller / @juancmuller

12/31/2010 at 04:15AM

54
#386 - Justin Knag / @justinknag

08/28/2014 at 11:28AM

55
#387 - Alexey Komissarouk / @alexeymk

12/29/2010 at 01:19PM

55
#388 - smokey42 / @smokey42

12/29/2010 at 02:34PM

55
#389 - Ed Gibbs / @edward_gibbs

08/17/2011 at 02:22PM

55
#390 - Ska / @skaa42

07/16/2021 at 06:51PM