Neovim:如何将钥匙发送到终端模拟器
当我打开NVIM终端模拟器并输入以下命令时,尝试执行命令“ python”:
:normal! ipython
事实证明,寄存器内容粘贴到了屏幕上,就好像在正常模式下按了“ p”,即使'i i i'已经在(据说)输入终端插入模式之前按下。
这也无济于事:
:execute "normal! ipython\<CR>"
我在哪里出了问题,我该怎么做正确的?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
feedkeys()
解决问题。因此,在正常模式下在终端缓冲区中执行以下命令在提示上产生“ Python”,就像用户键入: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:并不意味着“运行程序”。它的意思是“切换到正常模式并运行
!
”,这是 filter命令;然后运行i
,即切换到插入模式并插入“ Python”。从VIM命令行运行命令使用
doesn't mean "run the program". It means "switch to Normal mode and run
!
" which is a filter command; then runi
that is switch to Insert mode and insert "python".To run a command from the vim command line use
我建议您使用
feedkeys()
,因为它需要您考虑切换模式,避免映射和逃脱。另外,由于其缓冲性(win_gotoid(term_window); feedkeys(“ als \&lt; cr&gt;”); win_gotoid(current_window)
将插入“ ls” ls“ ls”,此外当前窗口,没有一个终端)。更好的解决方案是使用
chansend(window_channel,“ ls \ n”)
,您可以从b:terminal_job_id
中找到通道号。I recommend against
feedkeys()
as it requires you to consider switching modes, avoiding mapping and escaping. Plus it cannot be used on non-current window due to its buffered nature (win_gotoid(term_window); feedkeys("als\<CR>"); win_gotoid(current_window)
will insert "ls" in current window, not one with terminal).Better solution is to use
chansend(window_channel, "ls\n" )
, you can find the channel number fromb:terminal_job_id
.