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

Vim、Emacs配置和使用
回复
罗非鱼
帖子: 980
注册时间: 2008-04-12 12:44

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

#1

帖子 罗非鱼 » 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的结果,输出在这个新开的窗口中?
头像
yjcong
帖子: 2470
注册时间: 2006-02-28 3:11

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

#2

帖子 yjcong » 2013-05-29 8:13

vim应该有可以自定义宏或快捷键的功能吧
一梦三年,
松风依旧,
萝月何曾老.


灵幽听微, 谁观玉颜?
灼灼春华, 绿叶含丹.
reallynotme
帖子: 157
注册时间: 2010-11-11 18:13
系统: Ubuntu

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

#3

帖子 reallynotme » 2013-05-29 9:12

与其在论坛上为每个小问题发一次贴,不如好好把vim的 user manual 看完,pdf的中文版也有
头像
xxxcjr
帖子: 102
注册时间: 2007-01-01 9:03

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

#4

帖子 xxxcjr » 2013-05-29 18:57

!python %

要更便捷就绑定一个快捷键。
头像
lainme
论坛版主
帖子: 7805
注册时间: 2008-09-13 19:17
系统: Arch Linux (x86_64)
联系:

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

#5

帖子 lainme » 2013-05-31 13:58

绑定快捷键
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

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

#6

帖子 eexpress » 2013-05-31 14:42

代码: 全选

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
自己改吧。
● 鸣学
回复