在 MATLAB 中,我们可以向编辑器写入以下内容
%% -- a example cell --
plot(rand(3));
%% -- another cell
A=rand(2^10);
t=linspace(-pi,pi,2^10);
compass(fft(A*sin(t))
我们只需点击Ctrl+Enter即可运行鼠标指针单击的单元格。
现在我知道在 Vim 中,我可以做到
:'<,>'w !matlab
运行视觉选择的代码块。
但是如何在 Vim/gVim 中实现类似 MATLAB 的单元格模式?
例如一些python代码
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)
谁能提供一些想法?