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

197 active golfers, 676 entries

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

02/01/2015 at 06:33AM

28
#62 - xieyh11 / @xieyh11

02/27/2015 at 03:23AM

28
#63 - BartJanssen / @BartJanssen

03/12/2015 at 10:37PM

28
#64 - pftb12345 / @pftb12345

04/07/2015 at 05:19AM

28
#65 - jakeroberts / @jakeroberts

05/28/2017 at 02:01AM

28
#66 - chaotic / @laersn

09/07/2018 at 02:58PM

29
#67 - RB / @powerage88

03/29/2014 at 04:55PM

29
#68 - Amit Verma / @amitv12

03/29/2014 at 06:20PM

29
#69 - Richard Veneracion / @rveneracion

05/25/2014 at 03:50AM

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

11/10/2015 at 02:10PM

30
#71 - Quota / @Quotad

03/30/2014 at 11:54AM

30
#72 - Brian Olpin / @bolpin

03/31/2014 at 05:03PM

30
#73 - Marcin Sza / @coot_

04/02/2014 at 07:03AM

30
#74 - Bambu / @bambumandinga

04/03/2014 at 12:30AM

30
#75 - David Barker / @dashleybarker

04/03/2014 at 08:36PM

30
#76 - Jean-Marie Comets / @jmcomets

04/04/2014 at 01:40PM

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

04/06/2014 at 12:56PM

30
#78 - Marcin Radomski / @_dextero

04/16/2014 at 12:53PM

30
#79 - Endir / @Endir2

04/17/2014 at 08:28PM

30
#80 - Aleksander Gajewski / @adgajewski

04/20/2014 at 05:02PM

30
#81 - Siah / @hydrospell

05/03/2014 at 05:47AM

30
#82 - Chaitanya Desu / @ChaituNu

05/03/2014 at 08:18PM

30
#83 - Vamshi Krishna / @pvamshi

05/07/2014 at 11:46AM

30
#84 - jolka / @jolka19296078

05/22/2014 at 01:34PM

30
#85 - Marco Biasini / @biasmv

08/01/2014 at 08:17PM

30
#86 - Florian Gauger / @FlorianGauger

06/05/2017 at 08:47PM

30
#87 - QingyuZhao / @zhao_qingyu

11/21/2017 at 09:22AM

31
#88 - Oddbike / @oddbike

04/01/2014 at 12:22PM

31
#89 - Marcin Cabaj / @marcincabaj

04/03/2014 at 08:07PM

31
#90 - usrbin / @notusrbin

04/09/2014 at 05:04PM