I found this vim tip which allows you to evaluate a Python expression and displays the result in the command line. You just have to add
:command! -nargs=+ Calc :py print <args> :py from math import *
.vimrc and then you can do e.g.
:Calc sum([x^2 for x in range(100)])
4950in my command line, as if I had executed
This is convenient, but I would like to know how I can either append the result at the location of my cursor, or add it to a certain register.