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

Add fold markers to a .c file

Fold markers can make it easier to navigate source code. Add them to this .c file.

Start file
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

void copy(char *to, char *from, size_t count) {
    register n=(count+7)/8;
    switch(count%8){
    case 0: do{     *to = *from++;
    case 7:         *to = *from++;
    case 6:         *to = *from++;
    case 5:         *to = *from++;
    case 4:         *to = *from++;
    case 3:         *to = *from++;
    case 2:         *to = *from++;
    case 1:         *to = *from++;
            }while(--n>0);
    }
}

int main() {
    char *input = malloc(sizeof(char) * 1024);
    assert(input);
    char *output = malloc(sizeof(char) * 1024);
    assert(output);
    copy(output, input, sizeof(char) * 1024);
    return 0;
}
End file
#include <string.h>/*{{{*/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
/*}}}*/

void copy(char *to, char *from, size_t count) {/*{{{*/
    register n=(count+7)/8;
    switch(count%8){
    case 0: do{     *to = *from++;
    case 7:         *to = *from++;
    case 6:         *to = *from++;
    case 5:         *to = *from++;
    case 4:         *to = *from++;
    case 3:         *to = *from++;
    case 2:         *to = *from++;
    case 1:         *to = *from++;
            }while(--n>0);
    }
}/*}}}*/

int main() {/*{{{*/
    char *input = malloc(sizeof(char) * 1024);
    assert(input);
    char *output = malloc(sizeof(char) * 1024);
    assert(output);
    copy(output, input, sizeof(char) * 1024);
    return 0;
}/*}}}*/

View Diff

1c1
< #include <string.h>
---
> #include <string.h>/*{{{*/
4a5
> /*}}}*/
6c7
< void copy(char *to, char *from, size_t count) {
---
> void copy(char *to, char *from, size_t count) {/*{{{*/
19c20
< }
---
> }/*}}}*/
21c22
< int main() {
---
> int main() {/*{{{*/
28c29
< }
---
> }/*}}}*/

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 111 remaining solutions by signing in and submitting your own entry
#112 drooooooooooo / droooooooooooo - Score: 46 - 08/08/11 @ 04:05
A/*{{{*/<Esc>vF/y6G$p15jp5Gi/*}}}*/<CR><Esc>kyf/20Gp9jpZZ

0 comments

#113 Oliver Christ / 0liverChrist - Score: 46 - 10/05/13 @ 22:28
qaA/*{{{*/<Esc>q3jo<Esc>qbA/*}}}*/<Esc>qjj@a20G@bjj@aG@bZZ

0 comments

#114 Nick / quinks25 - Score: 47 - 01/10/11 @ 06:05
qaA/*{{{*/<Esc>q3jA<CR><Esc>qbA/*}}}*/<Esc>q2j@a13j@b2j@aG@bZZ

0 comments

#115 Solomon White / rubysolo - Score: 47 - 02/08/11 @ 17:24
qaA/*{{{*/<Esc>q6G@a21G@A5GO<Esc>qaA/*}}}*/<Esc>q20G@AG@AZZ

0 comments

#116 Xavier Nayrac / lkdjiin - Score: 47 - 12/29/11 @ 15:04
qaA/*{{{*/<Esc>q6G@a21G@aGqaA/*}}}*/<Esc>q19G@a5GO<Esc>@aZZ

0 comments

#117 Yi EungJun / semtlnori - Score: 47 - 09/23/12 @ 12:15
3jo/*}}}*/<Esc>v0y15jpGp7k$a/*{{{*/<Esc>v6hy15k$pgg$pZZ

0 comments

#118 michael / pfista - Score: 47 - 07/02/13 @ 14:39
qqA/*{{{*/<Esc>q5GqwA/*}}}*/<Esc>qo<Esc>j@q20G@w2j@qG@w:wq<CR>

0 comments

#119 Israel Chauca F. / Raimondi - Score: 49 - 12/28/10 @ 23:37
qqA/*{{{*/<Esc>q}qrA/*}}}*/<Esc>qo<Esc>/ {<CR>@qn@q2k@rG@r:x<CR>

0 comments

#120 Martin Petrov / mgpetrov - Score: 49 - 08/23/12 @ 20:25
4Go/*}}}*/<Esc>0v$hy20GpGpgg$phhvhhr{$vF/y7G$p22G$pZZ

0 comments

#121 Arto Vuori / dhpe - Score: 49 - 08/30/12 @ 20:02
A/*{{{*/<Esc>vF/y/{<CR>3np3np?ass<CR>o/*}}}*/<Esc>vF/y)))kpGpZZ

0 comments

#122 krazylegz / krazylegz - Score: 50 - 12/28/10 @ 23:24
$pa/*{{{*/<Esc>vbly5j$p15jpGA/*}}}*/<Esc>vbly9kp:5<CR>po<Esc>:wq<CR>

0 comments

#123 Jonathan Wallace / jonathanwallace - Score: 51 - 12/29/10 @ 03:37
qqA/*{{{*/<Esc>q4jqwA/*}}}*/<Esc>qo<Esc>j@q20j20G@wjj@qG@WZZ

0 comments

#124 Alain Gilbert / alain_gilbert - Score: 51 - 12/30/10 @ 18:43
4Go/*}}}*/<Esc>vby20Gp29Gp22G$a/*{{{*/<Esc>vb<Right>y7G$p1G$pZZ

0 comments

#125 Eivind Jahren / HaskellElephant - Score: 51 - 03/27/11 @ 19:09
qaA/*{{{*/<Esc>q3jo/*}}}*/<Esc>jj@a20GqbA/*}}}*/<Esc>qjj@aG@bZZ

0 comments

#126 Nico Kruger / nicok_za - Score: 51 - 11/09/12 @ 12:14
qaA/*{{{*/<Esc>q3jjqsA/*}}}*/<Esc>q<Esc>jka<CR><Esc>j@a}k@s2j@aG@szzZZ

0 comments

#127 Thomas Schönwälder / Masei1988 - Score: 52 - 01/15/11 @ 20:38
A/*{{{*/<Esc>vF/y4/{<CR>p3/{<CR>p/}<CR>a/*}}}*/<Esc>vF/y2?}<CR>p:5<CR>po<Esc>ZZ

0 comments

#128 Birkir Ólafsson / Birkirlafsson - Score: 52 - 07/27/14 @ 13:38
A/*{{{*/<Esc>4jj.21G.Ga/*}}}*/<Esc>19G.5Gi<CR><Esc>k.ddki/*}}}*/<Esc>ZZ

0 comments

#129 うえっち / uh_tomo - Score: 55 - 12/04/12 @ 17:14
$qaa/*{{{*/q<BS><Esc>q:5<CR>qba/*}}}*/<Esc>qo<Esc>j$@a:20<CR>@bjj$@a:29<CR>@bZZ

0 comments

#130 くま55 / kumack55 - Score: 55 - 04/03/13 @ 13:38
A/*{{{*/<Esc>F/"qyf/4jP4h3r}0"wy$o<Esc>j$"qp:20<CR>"wp2j$"qpG"wpZZ

0 comments

#131 Eric Holmes / ejholmes01 - Score: 57 - 12/30/10 @ 05:22
qqA/*{{{*/<Esc>qjjjo<Esc>qwA/*}}}*/<Esc>q:7<CR>@q:20<CR>@w:22<CR>@q:29<CR>@w:wqa<CR>

0 comments

#132 Travis Jeffery / travisjeffery - Score: 57 - 11/16/11 @ 05:11
O<Esc>qqjA/*{{{*/<Esc>}q2@qo<Esc>qqkA/*}}}*/<Esc>{q@qO/*}}}*/<Esc>:1d<CR>:30d<CR>ZZ

0 comments

#133 Jeroen / teranex - Score: 59 - 03/04/11 @ 00:29
A/*{{{*/<Esc>vT>"ay3jo/*}}}*/<Esc>v0"byjj$"ap12jj"bpjj$"apG"bp<Esc>:wq<CR>

0 comments

#134 primitiveworker / primitiveworker - Score: 68 - 12/30/10 @ 00:17
$a/*{{{*/<Esc>v6hy))$p))$p)a/*}}}*/<Esc>v6hy((()<Up><Right>a<Esc>p(kO<Esc>p<Esc>:wq<CR>

0 comments

#135 Andrey A. Ugolnik / andreyugolnik - Score: 68 - 01/19/11 @ 22:58
A/*{{{*/<Esc>4ji/*}}}*/<CR><Down><End>/*{{{*/<Esc>20GA/*}}}*/<Esc>29GA/*}}}*/<Esc>22GA/*{{{*/<Esc>ZZ

0 comments

#136 drio / drio - Score: 69 - 12/30/10 @ 10:27
$a/*{{{*/<Esc>0f>lv$h"ay6G$"ap21G$"ap28Ga/*}}}*/<Esc>0lv$h"by19G"bp5G"bpo<Esc>:x<CR>

0 comments

#137 Eric Allen / ericpallen - Score: 81 - 12/28/10 @ 23:19
A/*{{{*/<Esc>F/"ay$jjjo/*}}}*/<Esc>^"by$jjA<Esc>pu"bpu"apjjjjjjjjjjjjj"bpjj$"apjjjjjjj"bp:wq<CR>

0 comments

#138 Kudryavtsev Alexandr / kudryav_a - Score: 85 - 12/16/12 @ 19:29
A/*{{{*/<Esc>v%"1y4jP<Esc>uO<C-R>1<C-R>2F<C-H><Esc>4l4hR}}}<Esc>%%^v%"2y:regi<NL><NL>2jA<C-R>1<C-R>20<Esc>uA<C-R>1<Esc>20GA<C-R>2<Esc>2jA<C-R>1<Esc>GA<C-R>2<Esc>ZZ

0 comments

#139 Felipe Jaramillo F / mrfelipe - Score: 126 - 06/06/14 @ 22:18
$I<Esc>$i<Esc>$$A/*{{{*/<Esc>5Gi/*}}}*/<CR>j<BS><Esc>kjj$A/*{{{*/<Esc><Left><Left><Left><Left><Left><Left>y$jjjjjjjjjjjjjPupujj$pkkkkkkkkkkkkkkkkkkj0y$jjjjjjjjjjjjjjjpjjjjjjjjjpo<Esc>uZZ

0 comments

Created by: wolever

139 active golfers, 425 entries

Leaderboard (lowest score wins):
30
#1 - h_east (トロッコ6個) / h_east

01/13/2011 at 04:10PM

30
#2 - Wei Dai / clvv42

01/13/2011 at 08:53PM

30
#3 - Oleg Roshupkin / jjjahson

01/25/2011 at 03:57PM

30
#4 - vg / vimgolfer

02/23/2011 at 10:54AM

30
#5 - Ruy Diaz / diazruy

03/17/2011 at 06:06AM

30
#6 - Craig H. Anderson / CootCraig

04/19/2011 at 08:45PM

30
#7 - Justin Love / wondible

06/10/2011 at 03:56PM

30
#8 - Jason Then / racc69

08/09/2011 at 12:03AM

30
#9 - sjatkinson / sjatkinson

08/31/2011 at 03:15AM

30
#10 - Derrick Spell / dcsesq

09/28/2011 at 03:32AM

30
#11 - Ravil Bayramgalin / brainopia

10/19/2011 at 01:29PM

30
#12 - vimja / vimja666

11/05/2011 at 12:32AM

30
#13 - You-Siang Lin / yslinnctu

11/28/2011 at 12:58PM

30
#14 - Ali Moeeny / alimoeeny

12/16/2011 at 11:49PM

30
#15 - Renat Aksitov / Korvin79

02/06/2012 at 04:19AM

30
#16 - Zeh Rizzatti / zehrizzatti

02/06/2012 at 04:20AM

30
#17 - Federico Galassi / federicogalassi

02/22/2012 at 02:43AM

30
#18 - Pawel Obrok / mrYapee

03/13/2012 at 08:36PM

30
#19 - Rod Knowlton / codelahoma

05/26/2012 at 09:44PM

30
#20 - Urtica dioica / udioica

06/11/2012 at 08:23PM

30
#21 - mwatkward / AftrschoolSpe

06/25/2012 at 09:19PM

30
#22 - Kerson Hsiao / KersonHsiao

08/07/2012 at 09:05AM

30
#23 - Charles Gordon / liberalbias

08/25/2012 at 09:55PM

30
#24 - Conner McDaniel / connermcd

09/18/2012 at 05:31PM

30
#25 - Vim rocks / vimrocks

10/06/2012 at 02:51PM

30
#26 - Marcin Sza / coot_

12/01/2012 at 01:25PM

30
#27 - Hubba / HubbaBubbaFett

12/01/2012 at 09:08PM

30
#28 - a24f0600 / a24f0600

12/14/2012 at 06:04PM

30
#29 - Averell Dalton / webtwoosucks

01/02/2013 at 11:29PM

30
#30 - Jimmy Mabey / mabeyj

01/20/2013 at 04:01AM

30
#31 - xavier kt / xav_kt

02/03/2013 at 08:48PM

30
#32 - Matt Adelman / Xavierstein

03/20/2013 at 07:44PM

30
#33 - Trevor Powell / DoomedBunnies

03/21/2013 at 05:24AM

30
#34 - Marco Hinz / _mhinz_

05/26/2013 at 05:22PM

30
#35 - Petro Тrouq / zulolosi

06/23/2013 at 03:29AM

30
#36 - spintriae / spintriae

10/20/2013 at 04:14PM

30
#37 - John Braxler / braxler

05/07/2014 at 06:03PM

30
#38 - Jonathan Crossley / _jcrossley

09/06/2015 at 04:12PM

30
#39 - Jon Krause / jkrause314

04/10/2016 at 09:49PM

31
#40 - Matt Tarbit / mtarbit

01/09/2011 at 09:07AM

31
#41 - Andrey Ivanov / Bytamine

01/19/2011 at 08:29PM

31
#42 - vansan / VinceVansan

08/25/2012 at 06:26PM

31
#43 - Brendan Op 't Root / OptrootB

08/29/2012 at 07:59PM

31
#44 - Darcy Parker / DarcyParker

10/16/2012 at 10:05PM

31
#45 - James / Dronak

09/05/2013 at 01:44PM

31
#46 - thasso / thasso23

11/16/2013 at 07:15PM

32
#47 - Mikel Ward / mikelward

12/31/2010 at 12:59AM

32
#48 - dominique pellé / vimgolfisto

01/03/2011 at 10:45PM

32
#49 - Tim Chase / gumnos

01/08/2011 at 04:24AM

32
#50 - Stephen Morrow / yawmark

01/26/2011 at 02:22PM

32
#51 - Hu Junfeng / junfeng

07/15/2011 at 11:39AM

32
#52 - OMF / exolon

05/29/2012 at 01:52AM

32
#53 - Joonas Pihlajamaa / jokkebk

02/20/2014 at 09:30PM

33
#54 - Pete Johns / johnsyweb

01/08/2011 at 12:53AM

34
#55 - dagbrown / dagbrown

12/28/2010 at 11:58PM

34
#56 - Dan Callahan / callahad

12/29/2010 at 08:29AM

34
#57 - Akira Matsuda / a_matsuda

12/30/2010 at 02:05PM

34
#58 - Balkoth / _Balkoth_

01/01/2011 at 01:26AM

34
#59 - Fer Enaf / 0x00C0FFEE

01/04/2011 at 11:33PM

34
#60 - Tim Dean / Tmdean

01/05/2011 at 08:47PM

34
#61 - Dezső Zoltán / zakiazigazi

01/22/2011 at 08:02AM

34
#62 - Rob Ciaccio / RobertoCalavera

01/23/2011 at 03:53AM

34
#63 - William Dunand / wdunand

12/08/2011 at 06:49AM

34
#64 - Tesnorth / Tesnorth

01/31/2012 at 04:36PM

34
#65 - 無ん垢の叫び / john_ababa

02/22/2012 at 02:04PM

34
#66 - Yann Moisan / YannMoisan

02/02/2013 at 01:35PM

34
#67 - cj / cj01101

08/27/2013 at 02:21AM

34
#68 - brett / brettyukich

09/23/2013 at 04:46AM

35
#69 - Aaron Bull Schaefer / elasticdog

12/28/2010 at 11:20PM

35
#70 - uuu / uu59

12/30/2010 at 06:34PM

35
#71 - Simon's Calf / simonscarfe

08/31/2011 at 08:43PM

35
#72 - Tara Bass / tara_bass

01/02/2012 at 12:57AM

36
#73 - Charlie Liang Yuan / _cly_

01/05/2011 at 02:37AM

36
#74 - Ilya Strukov / i1ey

05/01/2011 at 05:56PM

36
#75 - Hannibal7878 / Hannibal7878

07/15/2011 at 04:15AM

36
#76 - Jesús Espino / jespinog

09/06/2011 at 09:23AM

36
#77 - Chris Brown / engineercyb

07/13/2012 at 03:22AM

36
#78 - Underhill Labs / underhilllabs

10/30/2012 at 01:49AM

36
#79 - Mikko Loponen / lopossumi

11/08/2012 at 05:34PM

36
#80 - Tamás Kárándi / tkarandi

12/06/2012 at 10:42PM

36
#81 - Alec Goebel / zego5360

01/07/2013 at 02:18AM

36
#82 - devper94 / devper94

03/16/2014 at 10:20AM

37
#83 - Katie Kennedy / cappy_haddock

12/30/2010 at 07:47PM

37
#84 - AD / golferTest101

01/01/2011 at 05:20PM

37
#85 -  Ikhsan Maulana / ixandidu

01/02/2011 at 09:05AM

37
#86 - Roman Mašek / romario333

01/05/2011 at 07:46PM

37
#87 - Wesley Wong / wesleymwwong

01/29/2011 at 09:10AM

37
#88 - mightyfoo / mightyfoo

05/25/2011 at 02:14PM

37
#89 - xaizek / xaizek

07/21/2011 at 06:26PM

37
#90 - Ivan Evtukhovich / evtuhovich

08/02/2011 at 05:08AM

37
#91 - Dave / zzdave13

08/02/2011 at 08:06PM

37
#92 - Rambominator / Rambominator

12/13/2011 at 08:40AM

37
#93 - mattn / mattn_jp

02/02/2012 at 07:11AM

37
#94 - Kristopher Urie / kristopherurie

02/11/2012 at 06:14AM

37
#95 - Dave Ingram / dmi

11/21/2012 at 06:36PM

37
#96 - Tom Duijf / tomduijf

01/29/2013 at 11:26PM

37
#97 - Steve Tjoa / stevetjoa

01/30/2013 at 08:43AM

37
#98 - ltn614 / ltn614

09/29/2015 at 10:42AM

37
#99 - Walker Boh / walker_boh

12/02/2015 at 12:51PM

38
#100 - Matthew Draper / _matthewd

12/31/2010 at 01:30AM

38
#101 - Guillaume Bonnoron / gbonnoron

12/31/2010 at 12:44PM

38
#102 - Niels Madan / nielsmadan

01/23/2013 at 01:19PM

38
#103 - pikaren / REALpikaren

01/23/2014 at 11:44AM

38
#104 - Skúli Jóhannsson / skulibj

06/28/2015 at 07:31PM

39
#105 - Mike Plotz / antisuji

12/30/2010 at 02:08AM

39
#106 - 4L41N / 4L41N1

11/21/2012 at 04:34PM

40
#107 - Jordan Lewis / JordanALewis

12/29/2010 at 08:15PM

43
#108 - Mike Marion / mikejmarion

03/22/2011 at 07:09AM

43
#109 - Tyler / tylerbindon

03/31/2013 at 05:35AM

44
#110 - Eric Potter / pottereric

06/09/2013 at 03:06AM

46
#111 - RolfK / mindleftbody

06/17/2011 at 12:50PM

46
#112 - drooooooooooo / droooooooooooo

08/08/2011 at 04:05AM

46
#113 - Oliver Christ / 0liverChrist

10/05/2013 at 10:28PM

47
#114 - Nick / quinks25

01/10/2011 at 06:05AM

47
#115 - Solomon White / rubysolo

02/08/2011 at 05:24PM

47
#116 - Xavier Nayrac / lkdjiin

12/29/2011 at 03:04PM

47
#117 - Yi EungJun / semtlnori

09/23/2012 at 12:15PM

47
#118 - michael / pfista

07/02/2013 at 02:39PM

49
#119 - Israel Chauca F. / Raimondi

12/28/2010 at 11:37PM

49
#120 - Martin Petrov / mgpetrov

08/23/2012 at 08:25PM

49
#121 - Arto Vuori / dhpe

08/30/2012 at 08:02PM

50
#122 - krazylegz / krazylegz

12/28/2010 at 11:24PM

51
#123 - Jonathan Wallace / jonathanwallace

12/29/2010 at 03:37AM

51
#124 - Alain Gilbert / alain_gilbert

12/30/2010 at 06:43PM

51
#125 - Eivind Jahren / HaskellElephant

03/27/2011 at 07:09PM

51
#126 - Nico Kruger / nicok_za

11/09/2012 at 12:14PM

52
#127 - Thomas Schönwälder / Masei1988

01/15/2011 at 08:38PM

52
#128 - Birkir Ólafsson / Birkirlafsson

07/27/2014 at 01:38PM

55
#129 - うえっち / uh_tomo

12/04/2012 at 05:14PM

55
#130 - くま55 / kumack55

04/03/2013 at 01:38PM

57
#131 - Eric Holmes / ejholmes01

12/30/2010 at 05:22AM

57
#132 - Travis Jeffery / travisjeffery

11/16/2011 at 05:11AM

59
#133 - Jeroen / teranex

03/04/2011 at 12:29AM

68
#134 - primitiveworker / primitiveworker

12/30/2010 at 12:17AM

68
#135 - Andrey A. Ugolnik / andreyugolnik

01/19/2011 at 10:58PM

69
#136 - drio / drio

12/30/2010 at 10:27AM

81
#137 - Eric Allen / ericpallen

12/28/2010 at 11:19PM

85
#138 - Kudryavtsev Alexandr / kudryav_a

12/16/2012 at 07:29PM

126
#139 - Felipe Jaramillo F / mrfelipe

06/06/2014 at 10:18PM