使用 Gvim 执行 Python [英] Executing Python with Gvim

查看:26
本文介绍了使用 Gvim 执行 Python的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  • 打开 gVim.
  • 然后使用 File Menu 和 MenuItem Open 打开一个文件 pi.py,其中包含以下小脚本:

如何使用 gVim 执行此代码?

How do I execute this code using gVim?

编辑

如果我使用 :!python pi.py:w !python - 然后我得到以下内容:

If I use either :! python pi.py or :w !python - then I get the following:

推荐答案

您不需要保存文件,您可以通过键入将当前缓冲区作为 stdin 运行到诸如 python 之类的命令:

You don't need to save the file, you can run the current buffer as stdin to a command such as python by typing:

:w !python -

(末尾的连字符可能不是必需的,python 通常默认使用 stdin)

(The hyphen at the end probably isn't necessary, python will generally use stdin by default)

鉴于您是 vim 新手,请注意这不会保存文件,只会运行它.您可能想了解如何保存文件.

edit: seeing as you are new to vim, note that this will not save the file, it will just run it. You will probably want to learn how to save your file.

这篇关于使用 Gvim 执行 Python的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆