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 53369b712a09c1000223fb57

Two become one

We have two c arrays and want to make one two dimensional out of it. Can we do that?

Start file
/* Frame (32 bytes) */
static const unsigned char pkt1[32] = {
0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
};

/* Frame (32 bytes) */
static const unsigned char pkt2[32] = {
0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
};
End file
/* Frame (32 bytes) */
static const unsigned char pkt1[2][32] = {
	{
	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
	0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
	0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
	},
	{
	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
	0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
	0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
	}
};

View Diff

2,14c2,14
< static const unsigned char pkt1[32] = {
< 0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
< 0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
< 0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
< 0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
< };
< 
< /* Frame (32 bytes) */
< static const unsigned char pkt2[32] = {
< 0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
< 0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
< 0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
< 0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
---
> static const unsigned char pkt1[2][32] = {
> 	{
> 	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
> 	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
> 	0x05, 0xdc, 0x1b, 0xe3, 0x40, 0x00, 0x31, 0x06, /* ....@.1. */
> 	0xe8, 0xc8, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8  /* ........ */
> 	},
> 	{
> 	0x08, 0x60, 0x6e, 0xf1, 0x3c, 0xb9, 0x9c, 0xc7, /* .`n.<... */
> 	0xa6, 0x35, 0x08, 0x12, 0x08, 0x00, 0x45, 0x00, /* .5....E. */
> 	0x05, 0xdc, 0x6b, 0x98, 0x40, 0x00, 0x31, 0x06, /* ..k.@.1. */
> 	0x99, 0x13, 0xcb, 0xd9, 0x00, 0xda, 0xc0, 0xa8, /* ........ */
> 	}

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 207 remaining solutions by signing in and submitting your own entry
#208 Peter Lustig / @germecon - Score: 123 - 08/06/14 @ 17:46
<C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up><C-><Up>j\\f1ijku<Esc>ua[]2<BS>jk<BS><BS><Esc>ba2<Esc>jkoi<BS>{jj<BS><BS><Esc>jjjjjwklrqr,jdd.d5wxxxxxxx\\f}/}<CR>a<CR>}jk<BS><BS><Esc>kkkkkkkkkkkkVjjjjjjjjjjj><Esc>:wq<CR>

0 comments


Created by: @saschagrunert

208 active golfers, 713 entries

Leaderboard (lowest score wins):
28
#61 - kwa / @kwa129

07/05/2014 at 11:25AM

28
#62 - James Scriven / @JamesDScriven

07/06/2014 at 06:58PM

28
#63 - Michael Comerford / @MComerford1

09/20/2014 at 02:45AM

28
#64 - eBrnd / @eBrnd

11/02/2014 at 04:17PM

28
#65 - Filipe Dias-L. / @sockyrc

12/07/2014 at 02:43PM

28
#66 - mark0829 / @mark0829

02/01/2015 at 06:33AM

28
#67 - xieyh11 / @xieyh11

02/27/2015 at 03:23AM

28
#68 - BartJanssen / @BartJanssen

03/12/2015 at 10:37PM

28
#69 - pftb12345 / @pftb12345

04/07/2015 at 05:19AM

28
#70 - jakeroberts / @jakeroberts

05/28/2017 at 02:01AM

28
#71 - chaotic / @laersn

09/07/2018 at 02:58PM

28
#72 - Иван / @wansmer

04/25/2023 at 02:00PM

29
#73 - RB / @powerage88

03/29/2014 at 04:55PM

29
#74 - Amit Verma / @amitv12

03/29/2014 at 06:20PM

29
#75 - Richard Veneracion / @rveneracion

05/25/2014 at 03:50AM

29
#76 - Árpád Krejczinger / @krarpi

11/10/2015 at 02:10PM

30
#77 - Quota / @Quotad

03/30/2014 at 11:54AM

30
#78 - Brian Olpin / @bolpin

03/31/2014 at 05:03PM

30
#79 - Marcin Szamotulski / @me_coot

04/02/2014 at 07:03AM

30
#80 - Bambu / @bambumandinga

04/03/2014 at 12:30AM

30
#81 - David Barker / @dashleybarker

04/03/2014 at 08:36PM

30
#82 - Jean-Marie Comets / @jmcomets

04/04/2014 at 01:40PM

30
#83 - ところたん / @tokoro10g

04/06/2014 at 12:56PM

30
#84 - Marcin Radomski / @_dextero

04/16/2014 at 12:53PM

30
#85 - Endir / @Endir2

04/17/2014 at 08:28PM

30
#86 - Aleksander Gajewski / @adgajewski

04/20/2014 at 05:02PM

30
#87 - Siah / @hydrospell

05/03/2014 at 05:47AM

30
#88 - Chaitanya Desu / @ChaituNu

05/03/2014 at 08:18PM

30
#89 - Vamshi Krishna / @pvamshi

05/07/2014 at 11:46AM

30
#90 - jolka / @jolka19296078

05/22/2014 at 01:34PM