In MATLAB, we can write to the editor the following
%% -- a example cell --
plot(rand(3));
%% -- another cell
A=rand(2^10);
t=linspace(-pi,pi,2^10);
compass(fft(A*sin(t))
and we can just hit Ctrl+Enter to run the cell being clicked by the mouse pointer.
Now I know in Vim, I can do
:'<,>'w !matlab
to run a visually selected block of code.
But how do I implement the MATLAB-like cell mode in Vim/gVim?
For example some python code
import os
import subprocess
import random
## 1st cell
ps =["python", "-h"]
out = subprocess.Popen(ps).communicate()[0]
print out
## 2nd cell
# import random -sould not be needed if we concatenate the import section and the cell
print random.randint(1,100)
Can anyone offer some ideas?