我这样在vim中,执行python程序
1.vim /tmp/test.py
2.编辑完成这个test.py文件后,进入命令行, :! python /tmp/test.py
程序就顺利执行了,现在,我想做到
1.! python /tmp/test.py 有点累赘,我要执行的就是我当前编辑的文件,有无简洁的写法?
2.可否新开一个窗口,让执行python的结果,输出在这个新开的窗口中?
如何更加简洁的执行python程序?
-
- 帖子: 980
- 注册时间: 2008-04-12 12:44
- yjcong
- 帖子: 2470
- 注册时间: 2006-02-28 3:11
-
- 帖子: 157
- 注册时间: 2010-11-11 18:13
- 系统: Ubuntu
Re: 如何更加简洁的执行python程序?
与其在论坛上为每个小问题发一次贴,不如好好把vim的 user manual 看完,pdf的中文版也有
- xxxcjr
- 帖子: 102
- 注册时间: 2007-01-01 9:03
Re: 如何更加简洁的执行python程序?
!python %
要更便捷就绑定一个快捷键。
要更便捷就绑定一个快捷键。
- lainme
- 论坛版主
- 帖子: 7805
- 注册时间: 2008-09-13 19:17
- 系统: Arch Linux (x86_64)
- 联系:
- eexpress
- 帖子: 58428
- 注册时间: 2005-08-14 21:55
- 来自: 长沙
Re: 如何更加简洁的执行python程序?
代码: 全选
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
● 鸣学