V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
leisurelylicht
V2EX  ›  Python

求问关于 vim 编译支持 Python 的问题

  •  
  •   leisurelylicht · 2017-12-28 11:56:24 +08:00 · 2429 次点击
    这是一个创建于 2282 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我想问下 vim 编译支持 python 和编译不支持 python,有什么区别吗?

    还有 vim 好像不能同时支持 python2 和 python3,那这两者之间有什么区别吗?是会影响关键字检查之类的吗?

    如果没法同时支持,2、3 都写来的人该怎么办?
    8 条回复    2017-12-28 14:23:18 +08:00
    maxxxxx
        1
    maxxxxx  
       2017-12-28 12:16:42 +08:00 via iPhone
    支持的话大概就是 Vimscript 里可以嵌 python 了,挑插件的话筛一下不依赖 python 的
    OscarUsingChen
        2
    OscarUsingChen  
       2017-12-28 12:25:09 +08:00 via iPhone
    楼主关注的是写代码的时候的自动完成等等吧?这个要交给第三方插件。Vim 的 Python Flag 是决定 Vim 能执行什么版本的脚本的
    xi2008wang
        3
    xi2008wang  
       2017-12-28 12:54:10 +08:00
    xi2008wang
        4
    xi2008wang  
       2017-12-28 12:54:49 +08:00
    siteshen
        5
    siteshen  
       2017-12-28 13:42:23 +08:00
    别想同时支持 python2 和 python3 了,对代码和其他工具( flake8 等)要求太高。
    也许可以根据「正在编辑」的文件动态设置要使用的 python 版本。

    根据当前正在编辑的文件是 python2 还是 python3 (在 vim script 判断? project 判断?),然后使用对应的 python 版:

    def is_python3(src):
    return project_name in ['proj1', 'proj2'] or first_line.contains('python3')

    if is_python3(src)
    alias python = python3
    else
    alias python = python2
    glues
        6
    glues  
       2017-12-28 14:04:52 +08:00
    你说的支持 python 是指的 Vim 插件要求的 python 版本,并不是你写代码的 python 版本
    所以直接选 3 就好了
    leisurelylicht
        7
    leisurelylicht  
    OP
       2017-12-28 14:22:48 +08:00
    @maxxxxx
    @OscarUsingChen
    原来如此,也就是说只要我用的 vim 插件不要求使用 python3,那我编译时候就用 python2 就行。

    跟我写什么版本的代码没关系。
    leisurelylicht
        8
    leisurelylicht  
    OP
       2017-12-28 14:23:18 +08:00
    @glues 我切成 3,vim 打开直接报错了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   960 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 21:14 · PVG 05:14 · LAX 14:14 · JFK 17:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.