11

I am running IPython on Windows 7 and can use the %paste magic command to paste from the clipboard. However, I cannot copy from IPython to the clipboard. I want to copy code snippets from IPython and paste them back to a text editor.

Anyone know a fix for this?

dimo414
  • 47,227
  • 18
  • 148
  • 244
user2367853
  • 111
  • 1
  • 3
  • I've never used ipython on windows, but if it works like a standard terminal window there is a menu item for selecting which puts you into select mode. You can also change the properties to make selecting work in a more sane way. – Adrian Ratnapala May 09 '13 at 20:49

3 Answers3

7

Found this gist to add a %copy magic command, my fork adds supports osx/linux/windows platforms.

I have yet to test it on windows, so please tell me if you encounter any issues.

tutuDajuju
  • 10,307
  • 6
  • 65
  • 88
6

As mentioned by @AdrianRatnapala, you can right-click in the terminal window and select Mark, mark the code snippets you want to copy, and then right-click (the marked content is copied to the clipboard when you right-click).

A more "permanent way" to use this feature is to right-click on the title bar of the terminal window and choose Properties. Under the Options tab, tick the box next to QuickEdit Mode and save this setting.

A third option is to use IPython's Qt Console. You can use this by entering ipython qtconsole in the command prompt.

sodd
  • 12,482
  • 3
  • 54
  • 62
0

A real permanent mode is to do what sodd has told, but a little bit different:

Right click in the top of the shell window, but use default instead properties option, also select options and Quick edit mode. Now this setting will survive in the next shell activations.

So it's very easy to copy and paste

Drag and drop to draw a rectangle inside shell screen and press Enter. The content is is in Clipboard. After, if you can paste this in the shell it's just press Right key or outside, use the usual Ctrl+V.

The cool thing is that you can now omit the number of commands in the copy.

enter image description here

Paulo Buchsbaum
  • 2,471
  • 26
  • 29