Suppose I have a file with the following text:
aaa
bbb
ccc
bbb
ccc
eee
I need to add a missing line ddd
after the second occurrence of ccc
.
For that reason, use of the built-in search()
function, as suggested here, won't work, because that will find the first occurrence.
I have the beginnings of a vimscript function:
function! addLine()
normal /bbb
normal /bbb
" MISSING LINE
wq!
endfunction
Is it possible to do this just using normal mode etc? If so, how?