如何从python代码中退出vim函数?

时间:2016-02-23 11:15:56

标签: python function vim return exit

示例:

function! MyFunc()
   do this
   do that

python3 << endpython
if var = "something":
   return
else:
   do this
endpython

endfunction

return命令不起作用:
E880:无法在vim中处理python异常的SystemExit

使用exit()quit()

时相同

如何从python代码中退出vim函数?

1 个答案:

答案 0 :(得分:1)

怎么样:

function! MyFunc()
....

python << EOF

if ...:
   result=0
else:
   ...
   result=1

vim.command("let pyResult=%d"%result)
EOF

if pyResult == 0
   return
else
   ..........
endif
endfunction