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 4d42cde1e6dc010cb7000024

expand a list comprehension (python)

Please show your way to convert a list comprehension in python to an ordinary for-loop expression!

Start file
print [x**2 for x in xrange(10)]
End file
tmp = []
for x in xrange(10):
    tmp.append(x**2)
print tmp

View Diff

1c1,4
< print [x**2 for x in xrange(10)]
---
> tmp = []
> for x in xrange(10):
>     tmp.append(x**2)
> print tmp

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 94 remaining solutions by signing in and submitting your own entry
#95 David Burns / @AutomatedTester - Score: 146 - 01/28/11 @ 15:17
itmp = []<CR><Esc><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>v<Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>x<Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>pu<Left>o<Up><CR><Up><Esc>pi<Right>:<Down><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><CR><Up><Tab><BS>    tmp.append(<Esc><Down><Right>v<Right><Right><Right>x<Up>pi<Right>)<Down><BS><BS><BS>tmp<Esc><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left><Left>dw<Down>dd:wq<CR>

0 comments


Created by: @vimgolfer

95 active golfers, 240 entries

Leaderboard (lowest score wins):
42
#1 - xhtmlforum / @xhtmlforum

01/28/2011 at 10:51PM

42
#2 - Pete Johns / @johnsyweb

01/29/2011 at 12:48AM

42
#3 - Tim Chase / @gumnos

01/29/2011 at 12:56AM

42
#4 - Stephen Morrow / @yawmark

01/29/2011 at 02:48PM

42
#5 - Wei Dai / @clvv42

01/30/2011 at 03:58AM

42
#6 - Oleg Roshupkin / @jjjahson

02/01/2011 at 11:39AM

42
#7 - Ujjwol Lamichhane / @Ujjwol

02/03/2011 at 02:58AM

42
#8 - Balkoth / @_Balkoth_

02/03/2011 at 09:45PM

42
#9 - Hu Junfeng / @junfeng

08/01/2011 at 02:42PM

42
#10 - You-Siang Lin / @yslinnctu

11/30/2011 at 05:39AM

42
#11 - Urtica dioica / @udioica

12/16/2012 at 04:24AM

42
#12 - Marco Hinz / @_mhinz_

05/28/2013 at 08:19AM

42
#13 - John Braxler / @braxler

06/09/2014 at 10:16PM

42
#14 - Turkey Man / @lvturkeyman

12/18/2017 at 07:57AM

43
#15 - Federico Galassi / @federicogalassi

01/28/2011 at 09:52PM

43
#16 - flo / @c4p0ne

01/31/2011 at 01:06PM

43
#17 - Justin Love / @wondible

09/07/2011 at 12:54PM

43
#18 - Rändöm Tester / @mevcar

02/12/2012 at 03:59PM

43
#19 - William Dunand / @wdunand

03/06/2012 at 08:34AM

44
#20 - Michał Taszycki / @mehowte

01/29/2011 at 06:51PM

44
#21 - Joonas Pihlajamaa / @jokkebk

02/25/2014 at 03:25PM

45
#22 - Jon Krause / @jkrause314

04/18/2016 at 10:39PM

46
#23 - h_east (トロッコ6個) / @h_east

01/29/2011 at 07:26AM

47
#24 - Zak Johnson / @zakj

04/21/2011 at 01:41AM

47
#25 - Øystein Walle / @oysteinwalle

07/08/2011 at 08:15PM

47
#26 - Renat Aksitov / @Korvin79

02/26/2012 at 06:30PM

47
#27 - Kerson Hsiao / @KersonHsiao

08/03/2012 at 03:45AM

48
#28 - timhoa / @timhoa

01/29/2011 at 09:14PM

48
#29 - Ivan Nečas / @iNecas

01/31/2011 at 10:56PM

48
#30 - Christopher Erin / @MCNormalMode

09/27/2011 at 12:36AM