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

110 active golfers, 334 entries

Leaderboard (lowest score wins):
47
#31 - Zak Johnson / @zakj

04/21/2011 at 01:41AM

47
#32 - Øystein Walle / @oysteinwalle

07/08/2011 at 08:15PM

47
#33 - Renat Aksitov / @Korvin79

02/26/2012 at 06:30PM

47
#34 - Kerson Hsiao / @KersonHsiao

08/03/2012 at 03:45AM

48
#35 - timhoa / @timhoa

01/29/2011 at 09:14PM

48
#36 - Ivan Nečas / @iNecas

01/31/2011 at 10:56PM

48
#37 - Christopher Erin / @MCNormalMode

09/27/2011 at 12:36AM

49
#38 - Xavier Nayrac / @lkdjiin

01/08/2012 at 11:35AM

49
#39 - cj / @cj01101

02/05/2014 at 10:55PM

50
#40 - Eivind Jahren / @HaskellElephant

02/02/2011 at 10:14PM

50
#41 - Ibrahim Tencer / @ibrahimtencer

02/13/2012 at 04:40AM

50
#42 - Yann Moisan / @YannMoisan

01/13/2013 at 07:57PM

51
#43 - Dan Masquelier / @danmasq

07/01/2011 at 09:32PM

51
#44 - Jesús Espino / @jespinog

09/06/2011 at 10:29PM

51
#45 - じょんあば / @john_ababa

02/27/2012 at 08:04AM

51
#46 - Daniel Lundin / @danielundin

05/11/2012 at 12:20PM

51
#47 - John Piasetzki / @jpiasetz

07/13/2012 at 07:03AM

52
#48 - iCross / @iCrossOfficial

01/30/2011 at 07:46PM

52
#49 - Thom Hughes / @thom_hughes_1

03/27/2011 at 01:42PM

52
#50 - Nolen Royalty / @NolenRoyalty

04/20/2012 at 06:25PM

52
#51 - r. / @rmarvie

12/23/2014 at 09:05PM

52
#52 - RockerZZY / @rocker_zzy

08/11/2020 at 12:17PM

53
#53 - Tact Overflow / @muppling

02/07/2011 at 08:22PM

53
#54 - Arthur Hinh / @arthur_hinh

03/26/2011 at 04:20AM

53
#55 - Avinash Baliga / @avinashbaliga

03/27/2011 at 08:41PM

54
#56 - Artem Dudarev / @dudarev

01/30/2011 at 04:25PM

54
#57 - Joost / @vlabakje

02/12/2011 at 12:29AM

54
#58 - Nicola Paolucci / @durdn

02/25/2011 at 09:04PM

54
#59 - Mauro Persano / @fzort

11/22/2014 at 03:50PM

55
#60 - Jay Phillips / @jicksta

01/30/2011 at 09:15PM