[oeasy]python0016_在vim中直接运行python程序
- 开发
- 10
-
回忆上次内容
![](https://img-blog.csdnimg.cn/img_convert/a680d90937b74c07f22893556c98faf5.webp?x-oss-process=image/format,png)
- 每次都要 退出vim编辑器😴
- 才能 在shell中 运行python程序
- 有点麻烦
![](https://img-blog.csdnimg.cn/img_convert/ba12cfd7575b9e22325533c53931463d.webp?x-oss-process=image/format,png)
- 想要 不退出vim
- 直接在 vim应用 中
- 运行 py程序
- 可能吗?🤔
运行程序
尝试
- 在
vim
中
:
执行vim本身的命令
:!
执行外部 命令
- 外部 指的是 vim应用外部
- 也就是 shell环境中的命令
![](https://img-blog.csdnimg.cn/img_convert/903555b72d7f10a0f7e82e308187ed0d.webp?x-oss-process=image/format,png)
![](https://img-blog.csdnimg.cn/img_convert/7a91852b5140eb62b52902be202d6391.webp?x-oss-process=image/format,png)
执行 更多外部命令
![](https://img-blog.csdnimg.cn/img_convert/3f4fd96d86338ff3bccdf987178ab0db.webp?x-oss-process=image/format,png)
![](https://img-blog.csdnimg.cn/img_convert/dcd182fc8550caa4d959e26076411a12.webp?x-oss-process=image/format,png)
执行python3解释器
python3 oeays.py
![](https://img-blog.csdnimg.cn/img_convert/b1f8545f6399e59d719447c2e04d6b99.webp?x-oss-process=image/format,png)
- 整个的意思 就是
- 去到外面的shell环境 中
- 执行命令
python3 oeasy.py
- 回车
效果
![](https://img-blog.csdnimg.cn/img_convert/7ed89080956b8aab32a52747117df9b7.webp?x-oss-process=image/format,png)
回到vim
![](https://img-blog.csdnimg.cn/img_convert/fa79e7e6aa1e37f4eef7ee2c96d171cd.webp?x-oss-process=image/format,png)
观察剪贴板
![](https://img-blog.csdnimg.cn/img_convert/284d4ec50889b8500420a6a928d53b0e.webp?x-oss-process=image/format,png)
百分号
![](https://img-blog.csdnimg.cn/img_convert/bd76080c117ba98150092a2e796251f6.webp?x-oss-process=image/format,png)
- 可以用%
- 指代oeasy.py
- 作为python3的参数吗?
使用%
代表 当前文件
![](https://img-blog.csdnimg.cn/img_convert/5170a6395b45d9a5a21730321f0ebd7e.webp?x-oss-process=image/format,png)
- 下面这两句话 效果一样
- :!python3 oeasy.py
- :!python3 %
![](https://img-blog.csdnimg.cn/img_convert/2bbad9d38a9223a4a63b14b0f14e0942.webp?x-oss-process=image/format,png)
![](https://img-blog.csdnimg.cn/img_convert/6415442383c5efec5e6091aecd63cb7e.webp?x-oss-process=image/format,png)
保存运行一条龙
:w|!python3 %
|
的意思是 依次执行
- 先执行 前面的w
- 再执行 后边!python3 %
- 这个竖线
|
的位置
![](https://img-blog.csdnimg.cn/img_convert/1df2d42dba90d55d7209abc74f64566c.webp?x-oss-process=image/format,png)
![](https://img-blog.csdnimg.cn/img_convert/1cf4bc8e054e63d5ec18b6ce7a4023d5.webp?x-oss-process=image/format,png)
- 先执行
w
- 再执行
!python3 %
- 效果如何呢?
效果 一样
![](https://img-blog.csdnimg.cn/img_convert/243f2d03772bd6d8a8252b89acf65079.webp?x-oss-process=image/format,png)
快速运行
![](https://img-blog.csdnimg.cn/img_convert/e4a40e27c627e0becd8f669e6b20b166.webp?x-oss-process=image/format,png)
总结
![](https://img-blog.csdnimg.cn/img_convert/429f184da3df9b3178156a408f5f262c.webp?x-oss-process=image/format,png)
原文地址:https://blog.csdn.net/overmind/article/details/138555643
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若转载,请注明出处:https://www.suanlizi.com/kf/1788392994819411968.html
如若内容造成侵权/违法违规/事实不符,请联系《酸梨子》网邮箱:1419361763@qq.com进行投诉反馈,一经查实,立即删除!