Just in case it may be useful to somebody else, here is a vim config 
snippet for copy-pasting examples and doctests to the sage repl. 
(Improvements welcome!)

function! YankSageTest(type, ...)
    if a:0
        let lines = getline("'<", "'>")
    else
        let lines = getline("'[", "']")
    endif
    let pattern =  '^\s*\(sage\|\.\.\.\.\): '
    call filter(lines, {i, l -> l =~ pattern})
    call map(lines, {i, l -> substitute(l, pattern, "", "")})
    call setreg(v:register, join(lines, "\n"), "l")
endfunction
nnoremap <localleader>Y :set opfunc=YankSageTest<CR>g@
vnoremap <localleader>Y :<C-U>call YankSageTest(visualmode(), 1)<CR

-- 
Marc

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/r43f7d%24p5d%241%40ciao.gmane.io.

Reply via email to