I have program running in the neovim terminal window, and I want to interrupt it. I can do so by moving to the window, <C-W>l, going into insert mode, and pressing <Ctrl-C>. Normally, at this time, I want to move back to the editor window, so I press <Esc><C-W>h

If I record this sequence as a macro, it functions correctly when I replay the macro. But when I print out the macro, and assign it to a keystroke, it no longer functions.

nnoremap <LocalLeader>cc ^WlA^C^[^Wh

Even if I assign it using the <C- mappings, it does not function

nnoremap <LocalLeader>cc <C-W>lA<C-C><Esc><C-W>h

What happens instead is that it types the h in the terminal. I think the C-C 'absorbs' the <Esc>, but I don't know how to put a delay within in a set of keystrokes.

Multiple escapes also does not work.

It drives me crazy, knowing that this is possible because it works in the macro, but I just don't know how to specify it as a keyboard mapping.

  • You might have to work with tnoremap or term_sendkeys or whatever its called (a feedkeys-like function for terms)
    – D. Ben Knoble
    Sep 25 '21 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.