iPython
Save lines to file
%save filename line1 line2-line5 line8
# append to the file
%save -a filename line11
Write multiline function
%edit NAME_OF_FUNCTION
Search history (all sessions)
%history -g SEARCH_TERM
%save filename line1 line2-line5 line8
# append to the file
%save -a filename line11
%edit NAME_OF_FUNCTION
%history -g SEARCH_TERM