代码: 全选
map <C-F11> :call CompileRun()<CR>
func CompileRun()
exec "w"
if &filetype == 'python'
exec "!/usr/bin/python3 %"
endif
endfunc
上面的代码,为什么不起作用,我单独用命令 :!python3 test.py 就可以。按C-F11,无效。
我看不出哪里有问题,请大家帮看看。
代码: 全选
map <C-F11> :call CompileRun()<CR>
func CompileRun()
exec "w"
if &filetype == 'python'
exec "!/usr/bin/python3 %"
endif
endfunc
代码: 全选
map <C-1> :call CompileRun()<CR>
func CompileRun()
exec "w"
if &filetype == 'python'
exec "!python3 %"
endif
endfunc
Ctrl-1 在终端下是无效的,所以 Vim 暂不支持此组合键(即使在 GUI 中)。drongh 写了:vim搞不懂啊。我刚刚改成其它快捷键就不起作用了。
map <C-1>, 仅仅改了一个数字,就不行了。
代码: 全选
map <C-1> :call CompileRun()<CR> func CompileRun() exec "w" if &filetype == 'python' exec "!python3 %" endif endfunc