Search code examples
command-lineterminalneovim

Neovim: how to send keys to terminal emulator


When I open up a nvim terminal emulator and enter the following command, trying to execute command 'python':

:normal! ipython

It turned out the register content is pasted onto the screen, as if 'p' is pressed under normal mode, even if 'i' has been pressed in prior to (supposedly) enter terminal-insert mode.

This does not help either:

:execute "normal! ipython\<CR>"

Where have I gone wrong, and how could I do it correctly?


Solution

  • feedkeys() solves the issue. So executing the following command in terminal buffer in normal mode produce "python" on the prompt as if typed by the user:

    :call feedkeys('ipython')