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 55f9720b4a665c2acf0008c8

Lower cased and dashed strings

As I have to generate big fixtures files, I wanted to find a way to format input data the way described by start and end files. Especially the lower-cased-and-dashed ids Not so good to find a pure Vim way, that's why I submit this challenge ;)

Start file
Lôrem Ipsum
Dolor.eros
Auctor: eros (elémentum)
Tincïdunt, âc
End file
lorem-ipsum:
    name: "Lôrem Ipsum"
dolor-eros:
    name: "Dolor.eros"
auctor-eros-elementum:
    name: "Auctor: eros (elémentum)"
tincidunt-ac:
    name: "Tincïdunt, âc"

View Diff

1,4c1,8
< Lôrem Ipsum
< Dolor.eros
< Auctor: eros (elémentum)
< Tincïdunt, âc
---
> lorem-ipsum:
>     name: "Lôrem Ipsum"
> dolor-eros:
>     name: "Dolor.eros"
> auctor-eros-elementum:
>     name: "Auctor: eros (elémentum)"
> tincidunt-ac:
>     name: "Tincïdunt, âc"

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 12 remaining solutions by signing in and submitting your own entry
#13 Pete Sevander / Sevanteri - Score: 100 - 09/19/15 @ 18:41
yG:se fenc=us//translit ve=all|w|e<CR>guG:%s/\W\+/-/g|%s/-*$/:\r    name: "@"<CR>p:.,+3 norm D/@<C-V><CR>vP<CR>jdGZZ

0 comments

#14 Olivier Debon / OlivierSwift - Score: 101 - 09/17/15 @ 08:39
qqyyPgu$:s/./\=tr(submatch(0),'<0xc3><0xb4><0xc3><0xa9><0xc3><0xaf><0xc3><0xa2>','oeia')/g<CR>:s/[ -@]\+/-/g<CR>:s/-*$/:/e<CR><Down>i    name: "<Esc>A"<Esc><CR>q3@qZZ

Smylers2: A little more tweaking gets that approach down to 92: qqYPgu$:s/./\=tr(submatch(0),'<0xc3><0xb4><0xc3><0xa9><0xc3><0xaf><0xc3><0xa2>','oeia')/g|s/\W\+/-/g|s/-*$/:<CR><Down>i name: "<End>"<Esc><CR>q3@qZZ

1 comment

#15 Gustavo / gvillalta99 - Score: 106 - 09/16/15 @ 20:51
yG:se fenc=us//translit ve=all|w|e<CR>guG:%s/\W\+/-/g<CR>:%s/-\?$/:\r    name: "@"<CR>pG@qqq"aDdd?@<CR>x"aPG<Esc>q3@q<Esc>:wq<CR>

Smylers2: Nice. Keeping this same approach I can get that down to 90 as: yGguG:se fenc=us//translit|w|e|%s/\W\+/-/g|%s/-\?$/:\r name: "@"<CR><CR>pqqDdd/@<CR>"-Plx<C-O>q3@qZZ (I didn't submit that, because doing so would disappear my Ctrl+V method — which doesn't require knowing how many entries there are — that's currently on 93.)

Smylers2: Or even 89, by using * instead of \?, per @OlivierSwift (thanks).

2 comments

#16 Walker Boh / walker_boh - Score: 107 - 10/05/15 @ 11:35
:se enc=utf-8<CR>qqy$A:<CR>    name: ""<Esc>P+q3@qkhhraTcrikkllx%x%TlreF(xgglroqqVgu:s/[ /<BS>\t.<BS><BS>.]/=<BS>-/g<CR>jjq3@qkf,xZZ

0 comments

Created by: tophsic

16 active golfers, 39 entries

Leaderboard (lowest score wins):
60
#1 - Urtica dioica / udioica

01/12/2017 at 03:20AM

61
#2 - Smylers / Smylers2

09/17/2015 at 09:45PM

62
#3 - John Braxler / braxler

09/17/2015 at 05:08PM

62
#4 - joinvimgolf / joinvimgolf

09/23/2015 at 03:27AM

62
#5 - Carlos A Henríquez Q / lagunex

03/13/2016 at 02:51PM

63
#6 - Jorge / jherreso

07/27/2017 at 07:07AM

67
#7 - Lifepillar / lifepillar

09/17/2015 at 10:08PM

70
#8 - Mike Adams / davis_cromwell

10/01/2015 at 02:50AM

79
#9 - andy / andy08028451

09/17/2015 at 12:28PM

81
#10 - Jon Krause / jkrause314

10/18/2015 at 04:06AM

83
#11 - Marcin Sza / coot_

09/17/2015 at 08:01AM

93
#12 - Rasmus P / rasmup

09/16/2015 at 09:24PM

100
#13 - Pete Sevander / Sevanteri

09/19/2015 at 06:41PM

101
#14 - Olivier Debon / OlivierSwift

09/17/2015 at 08:39AM

106
#15 - Gustavo / gvillalta99

09/16/2015 at 08:51PM

107
#16 - Walker Boh / walker_boh

10/05/2015 at 11:35AM