分页: 1 / 1

如何更加简洁的执行python程序?

发表于 : 2013-05-29 6:26
罗非鱼
我这样在vim中,执行python程序
1.vim /tmp/test.py
2.编辑完成这个test.py文件后,进入命令行, :! python /tmp/test.py
程序就顺利执行了,现在,我想做到
1.! python /tmp/test.py 有点累赘,我要执行的就是我当前编辑的文件,有无简洁的写法?

2.可否新开一个窗口,让执行python的结果,输出在这个新开的窗口中?

Re: 如何更加简洁的执行python程序?

发表于 : 2013-05-29 8:13
yjcong
vim应该有可以自定义宏或快捷键的功能吧

Re: 如何更加简洁的执行python程序?

发表于 : 2013-05-29 9:12
reallynotme
与其在论坛上为每个小问题发一次贴,不如好好把vim的 user manual 看完,pdf的中文版也有

Re: 如何更加简洁的执行python程序?

发表于 : 2013-05-29 18:57
xxxcjr
!python %

要更便捷就绑定一个快捷键。

Re: 如何更加简洁的执行python程序?

发表于 : 2013-05-31 13:58
lainme
绑定快捷键

Re: 如何更加简洁的执行python程序?

发表于 : 2013-05-31 14:42
eexpress

代码: 全选

map <F9> :call CompileRun()<CR>
func CompileRun() 
        exec "w" 
        if &filetype == 'c' 
        exec "!/usr/bin/gcc `pkg-config --cflags --libs gtk+-2.0 gmodule-2.0` % -g -o %<.run" 
        exec "!./%<.run" 
        elseif &filetype == 'perl' 
        exec "!perl %" 
        elseif &filetype == 'tex' 
        exec "!xelatex \'%\'; [ $? == 0 ] && nohup evince %:r.pdf &"
        elseif &filetype == 'markdown'
        exec "!markdown \'%\'>\'%.html\'; [ $? == 0 ] && nohup opera \'%.html\' &"
        elseif &filetype == 'dot'
        exec "!dot -Tsvg % -o %.svg; eog %.svg"
        elseif &filetype == 'vala'
        exec "!valac --pkg gtk+-3.0 %; ./%:t:r"
        endif 
endfunc
自己改吧。