Digraphs in Terminal mode

Is it possible to enter a digraph in Terminal mode? I tried typing <c-k> as I would in regular Insert mode, but the key combination was sent directly to the terminal.

you can copy special char to register and paste register on terminal mode

That’s pretty much the least-desirable option… I was hoping it would at least be possible to :tmap <c-k> to something that could enter a digraph. I guess I could have it open a scratch buffer, then copy the contents back into the terminal buffer, but that seems very complicated.

So I was curious to see if this could be done and I arrived at this, uh, “solution”:

function! s:inputdigraph() abort
    stopinsert
    let char1 = nr2char(getchar())
    let char2 = nr2char(getchar())
    call feedkeys(":call chansend(b:terminal_job_id, '\<C-k>" .. char1 .. char2 .. "')\<CR>", 'n')
    call feedkeys('i', 'n')
endfunction

tnoremap <C-k> <Cmd>call <SID>inputdigraph()<CR>

It’s not particularly pretty but it seems to work fine? If anyone knows how to do this in a non-hacky way, I’m all ears.

1 Like