-
Notifications
You must be signed in to change notification settings - Fork 225
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use ipython 5's new paste functionality to fix long lines issue #123
Comments
Hmmmm… does that just mean not turning on ipython mode? Or is there more to it? |
I took a 200 line python script, copied it to the system clipboard, and then just hit Cmd-V to paste it and it pasted with the correct indentation. I'm not sure how they implement it. I'd try not turning it on and see if that works. |
I was able to get this to partially work by turning on "bracked paste mode" (https://cirw.in/blog/bracketed-paste), instead of using
to
where I don't know enough about vimscript to make it check the current version of ipython (as multi-line pasting is version 5.0+). |
@jpalardy , "not turning on ipython mode" doesn't work because you need to send something special for "non-executing-newline"
See also: ENH: enable multiline send for ipython |
Based on what I'm reading, this is related to #142 ? |
For IPython 7.2, I managed to get it working with the following changes:
to
when vim-slime pastes the text, IPython 5.0+ will run the code with no problems, but it will not auto-execute. Adding the pause and the newline character makes IPython execute the code after pasting. Note that for large blocks of code with empty lines, there is still a problem with IPython executing at some of these empty lines, which seems to occur randomly, indicating a timing issue. This will be a problem for indented code. I'm not sure how to address this. |
I'll have to defer to an iPython user for a solution. |
If I replace empty lines with a comment character, it suppresses early execution and somewhat preserves the layout of the code. A bit hacky, but it seems to work. |
So... should I submit a pull request for testing perhaps? Or no? |
I'm up for it. If you send a PR, I'll merge it. If it doesn't work, we'll revert? |
New to this... hopefully it's OK. |
@NedWestern I've been using it (for the last two years) to send code from vim to ipython using tmux and it's removed the issue of ipython thinking I'm sending multiple chunks (as far as I can tell). Specifically replacing
with
It might let you avoid having to suppress empty lines with comment characters. |
@aicherc
Does it require specific settings in vim? |
@NedWestern Based on this, I like your current solution (empty lines -> |
True, but it seems to break for some people... ugh. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
I figured I'd make this a separate issue. I'll quote the text I added to another issue:
The text was updated successfully, but these errors were encountered: