I am trying to implement a vimscript function which appends to a terminal buffer. It works when I write this as a single mapping which uses the normal mode 'a' command to append:
nnoremap <Leader>glq :tabnew<CR>:terminal<CR>:set ft=instaflog<CR>als<CR>
But I want this in a function to make the code clearer. However, using
insert() I get the error stating that the terminal buffer is not modifiable, which I guess is strictly true, but every keypress is passed on to the terminal. So far, I have:
function! TerminalSomething() abort tabnew terminal set ft=instaflog startinsert execute "normal! Ayyy" endfunction
But the 'yyy' text doesn't appear; that execute line apparently does nothing for terminal buffers, even though it works for all other buffer types.