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):
40
#31 - JinHwan Choi / @jinhwanlazy

03/26/2016 at 06:50AM

40
#32 - Chenut Ludovic / @7Brwa7

04/04/2016 at 12:11PM

40
#33 - Jon Krause / @jkrause314

04/11/2016 at 08:46PM

40
#34 - Ameen P / @Ameen_P1

06/18/2016 at 10:06AM

40
#35 - sijinyuan / @sijinyuan

03/18/2017 at 06:00AM

40
#36 - DHM / @DHM29978992

04/30/2018 at 03:33AM

40
#37 - Brendan B Amdocs / @AmdocsB

09/27/2018 at 03:33PM

40
#38 - Mihai / @mihaicristiant

01/17/2019 at 03:57PM

40
#39 - Ivo Blöchliger / @aigledesalpes

08/23/2019 at 05:02PM

40
#40 - Jean George / @JeanGeo20504212

02/04/2022 at 10:03PM

40
#41 - Иван / @wansmer

04/23/2023 at 09:14PM

40
#42 - KoroneListener / @KoroneListener

09/04/2024 at 08:01AM

40
#43 - bounce114 / @bounce114

12/03/2024 at 07:26AM

41
#44 - dominique pellé / @vimgolfisto

01/01/2011 at 06:02PM

41
#45 - Akira Matsuda / @a_matsuda

01/05/2011 at 03:58PM

41
#46 - Wei Dai / @clvv42

01/07/2011 at 04:06AM

41
#47 - Balkoth / @_Balkoth_

01/08/2011 at 06:02PM

41
#48 - Federico Galassi / @federicogalassi

01/28/2011 at 09:40AM

41
#49 - Justin Love / @wondible

06/14/2011 at 01:59PM

41
#50 - Junfeng / @junfeng

07/17/2011 at 12:45PM

41
#51 - Albin Olsson / @sentenser

01/15/2012 at 10:40PM

41
#52 - Benoit Thiell / @benoitthiell

07/19/2012 at 10:20PM

41
#53 - Kerson Hsiao / @KersonHsiao

07/24/2012 at 07:08AM

41
#54 - Vim rocks / @vimrocks

10/06/2012 at 11:01PM

41
#55 - Hubba / @HubbaBubbaFett

12/16/2012 at 12:28PM

41
#56 - a24f0600 / @a24f0600

01/09/2013 at 10:05AM

41
#57 - Tyler / @tylerbindon

03/31/2013 at 09:44PM

41
#58 - Brent Carmer / @brent_carmer

04/09/2013 at 03:18AM

41
#59 - Trevor Powell / @DoomedBunnies

04/11/2013 at 04:55AM

41
#60 - Bradd Szonye / @bszonye

07/14/2013 at 09:50AM