[IPython-user] vim mapping for copying from the ipython history

Fernando Perez Fernando.Perez at colorado.edu
Thu Oct 20 12:42:46 CDT 2005


Ryan Krauss wrote:
> This may be useful to any VIM users on the list (but you probably
> already thought of it).  I do a fair ammount of copying and pasting
> from the ipython history into an existing file.  This mapping:
> :map <C-S-i> :%s/^\d\+:\s\+//<cr>
> removes the #:space from the beginning of those lines.
> 
> Ryan

Thanks for the tip.  Just as an fyi, you may want to know that the -n switch 
prevents these numbers from being printed in the first place:

In [1]: print 'hi Ryan'
hi Ryan

In [2]: import sys

In [3]: hist
1: print 'hi Ryan'
2: import sys

In [4]: hist -n
print 'hi Ryan'
import sys
ipmagic("hist ")


This makes it much easier to copy/paste.  You can also use the %save magic to 
dump a bunch of lines (not necessarily contiguous) to a file.  Type %save? for 
details.

Cheers,

f




More information about the IPython-user mailing list