When I am developing some python script, I regularly find myself running part of the code to see if it does what I want it to do. Currently I do this by copying the code that I want to run to the clipboard, alt-tabbing to the console and then
%pasteing the code into ipython.
Of course this procedure is far from ideal, which is why I want to make use of the new
term_sendkeys(). I can send code to ipython using
term_sendkeys(), but somehow I cannot get ipython to actually run the code. Below is a summary of my steps thus far:
First I start vim 8.1 using
vim -u NONE in a normal command prompt on Windows 7. Then I run
:term to create the terminal buffer. In this buffer I type
<c-w>:echo bufnr('%')<cr> to find the number of the buffer and find that the number is
2. Then I move to the text buffer and run two commands:
:call term_sendkeys(2, "ipython\<cr>") :call term_sendkeys(2, "a=1\<cr>")
The first starts ipython as expected. The second enters
a=1 and a newline. However, when I type the same sequence of keys in ipython hitting enter actual executes the statement instead of starting a new line. I therefore believe that either vim is sending another key than I think it's sending or that ipython treats keys received in this way differently than keys received from the user directly. What am I doing wrong?