i use this in my ~/.vimrc
file:
" calls maxima --very-quit -r "[ARG];"
function! AsciiMath(formula)
let cmdln='maxima --very-quiet -r "'.a:formula.';"'
let @a=system(cmdln)
if !v:shell_error
" echo @a
put a
else
echo '"'.a:formula.'" is an invalid maxima expression"'
endif
endfunction
and call it like:
:call AsciiMath("f(x):=e^(x/sqrt(x))")
i think the function is straght forward to understand, but there are some tricky parts:
put
requires a register as argument see:h registers
and:h put
- arguments cannot be used like
formula
they need the prefix (namespace)a:
use it likea:formula
. - if you have vim configured
to reload the
.vimrc
file then you should usefunction!
instead offunction
because otherwise you 'll get an error (something like "[FUNCTIONNAME] is allready defined") system()
returns the console output of its argument as returnvalue and puts the returnvalue of its argument inv:shell_error
.