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 55213dc25709ea0851015904

Custom McCarthy sequence

Generate the first one hundred and twenty numbers (starting with n=1). See here for some inspiration: http://en.wikipedia.org/wiki/McCarthy_91_function

Start file
" Humm... :so%

" Custom McCarthy 91 function
" M(n) = { n          if n > 97
"        { M(M(n+1))  if n <= 97
function! Mc98(n)
  if a:n > 97
    return a:n
  else
    return Mc98(Mc98(a:n + 1))
  endif
endfunction

function! Mc98Line()
  let l = getline('.')
  call setline('.', Mc98(l))
endfunction

" Humm...
"command! -range Mc98Cmd <line1>,<line2>call Mc98Line()
nmap M ciw<C-R>=Mc98(<C-R>")<CR><Esc>
"0put=range(1,120)
End file
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120

View Diff

1,22c1,120
< " Humm... :so%
< 
< " Custom McCarthy 91 function
< " M(n) = { n          if n > 97
< "        { M(M(n+1))  if n <= 97
< function! Mc98(n)
<   if a:n > 97
<     return a:n
<   else
<     return Mc98(Mc98(a:n + 1))
<   endif
< endfunction
< 
< function! Mc98Line()
<   let l = getline('.')
<   call setline('.', Mc98(l))
< endfunction
< 
< " Humm...
< "command! -range Mc98Cmd <line1>,<line2>call Mc98Line()
< nmap M ciw<C-R>=Mc98(<C-R>")<CR><Esc>
< "0put=range(1,120)
---
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 98
> 99
> 100
> 101
> 102
> 103
> 104
> 105
> 106
> 107
> 108
> 109
> 110
> 111
> 112
> 113
> 114
> 115
> 116
> 117
> 118
> 119
> 120

Solutions by @foobar01123:

Unlock 7 remaining solutions by signing in and submitting your own entry
Created by: @mcr05

15 active golfers, 36 entries

Solutions by @foobar01123:
15
#2 - Miłosz Łakomy / @foobar01123

12/30/2019 at 01:01PM

19
#>8 - Miłosz Łakomy / @foobar01123

12/30/2019 at 12:42PM

20
#>11 - Miłosz Łakomy / @foobar01123

12/30/2019 at 12:42PM

20
#>11 - Miłosz Łakomy / @foobar01123

12/30/2019 at 12:50PM

20
#>11 - Miłosz Łakomy / @foobar01123

12/30/2019 at 12:52PM

24
#>13 - Miłosz Łakomy / @foobar01123

12/30/2019 at 12:40PM

28
#>15 - Miłosz Łakomy / @foobar01123

12/30/2019 at 12:23PM