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

157 active golfers, 481 entries

Leaderboard (lowest score wins):
34
#61 - Balkoth / @_Balkoth_

01/01/2011 at 01:26AM

34
#62 - Fer Enaf / @0x00C0FFEE

01/04/2011 at 11:33PM

34
#63 - Tim Dean / @Tmdean

01/05/2011 at 08:47PM

34
#64 - Dezső Zoltán / @zakiazigazi

01/22/2011 at 08:02AM

34
#65 - Rob Ciaccio / @RobertoCalavera

01/23/2011 at 03:53AM

34
#66 - William Dunand / @wdunand

12/08/2011 at 06:49AM

34
#67 - Tesnorth / @Tesnorth

01/31/2012 at 04:36PM

34
#68 - 無ん垢の叫び / @john_ababa

02/22/2012 at 02:04PM

34
#69 - Yann Moisan / @YannMoisan

02/02/2013 at 01:35PM

34
#70 - cj / @cj01101

08/27/2013 at 02:21AM

34
#71 - brett / @brettyukich

09/23/2013 at 04:46AM

34
#72 - DHM / @DHM29978992

05/15/2018 at 03:10AM

34
#73 - Mihai / @mihaicristiant

03/22/2019 at 07:18AM

34
#74 - Tamás Kárándi / @tkarandi

10/19/2019 at 11:32AM

34
#75 - RockerZZY / @rocker_zzy

06/10/2020 at 11:39PM

34
#76 - Miłosz Łakomy / @foobar01123

06/13/2020 at 01:33PM

35
#77 - Aaron Bull Schaefer / @elasticdog

12/28/2010 at 11:20PM

35
#78 - uuu / @uu59

12/30/2010 at 06:34PM

35
#79 - Simon Scarfe / @simonscarfe

08/31/2011 at 08:43PM

35
#80 - Tara Bass / @tara_bass

01/02/2012 at 12:57AM

35
#81 - Scott Atkins / @scottrick49

06/29/2021 at 06:26PM

36
#82 - Charlie Liang Yuan / @_cly_

01/05/2011 at 02:37AM

36
#83 - Ilya Strukov / @i1ey

05/01/2011 at 05:56PM

36
#84 - Hannibal7878 / @Hannibal7878

07/15/2011 at 04:15AM

36
#85 - Jesús Espino / @jespinog

09/06/2011 at 09:23AM

36
#86 - Chris Brown / @engineercyb

07/13/2012 at 03:22AM

36
#87 - Underhill Labs / @underhilllabs

10/30/2012 at 01:49AM

36
#88 - Mikko Loponen / @lopossumi

11/08/2012 at 05:34PM

36
#89 - Alec Goebel / @zego5360

01/07/2013 at 02:18AM

36
#90 - devper94 / @devper94

03/16/2014 at 10:20AM