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
wsds
V2EX  ›  Python

这种长的一逼的不符合 pe8 的代码行,怎么缩短?不要这种高亮提示

  •  
  •   wsds · 2018-07-07 14:02:59 +08:00 · 3165 次点击
    这是一个创建于 2091 天前的主题,其中的信息可能已经有所发展或是发生改变。

    sublime 的 anaconda 插件升级了后,所有写的代码都被高亮了(一行太长了),怎么按要求格式化?自带的 autope8 只能格式化少量的,大部分还是不能自动格式化

    2di3jL.png

    11 条回复    2018-07-08 17:10:59 +08:00
    ericls
        1
    ericls  
       2018-07-07 14:29:11 +08:00 via iPhone
    yapf
    VVVVVEX
        2
    VVVVVEX  
       2018-07-07 14:34:07 +08:00
    call plug#begin('~/.vim/plugged')
    Plug 'Valloric/YouCompleteMe'
    Plug 'w0rp/ale'
    call plug#end()


    set ai
    set sw=4
    set ts=4
    set sts=4

    "pip3 install jedi
    let g:ycm_python_binary_path = '/usr/local/bin/python3'

    "pip3 install yapf
    let b:ale_fixers = ['yapf']
    wsds
        3
    wsds  
    OP
       2018-07-07 15:34:25 +08:00
    @VVVVVEX 老铁,这怎么用的啊
    VVVVVEX
        4
    VVVVVEX  
       2018-07-07 16:01:08 +08:00
    明显的 vim 配置文件啊,gayhub 上的一个项目抄来的,作者还写了一本书
    JCZ2MkKb5S8ZX9pq
        5
    JCZ2MkKb5S8ZX9pq  
       2018-07-07 17:06:00 +08:00
    这种 dict 嘛还是断行看得清楚点,缺点嘛就是注释的时候不能直接注释一行了。
    另外可以改 anaconda 的配置文件,对行内长度这条不要高亮。毕竟 useragent 啥的纯长 str 写断行不大自然。
    wsds
        6
    wsds  
    OP
       2018-07-07 17:24:26 +08:00
    @VVVVVEX /手动捂脸,怎么用啊
    likuku
        7
    likuku  
       2018-07-07 17:27:47 +08:00
    彻底点,太长超过 80 字符的,就分行重写。

    # 参考右边的 Google Python Style Guide
    VVVVVEX
        8
    VVVVVEX  
       2018-07-07 18:08:37 +08:00
    算了,你不会 vim
    ytmsdy
        9
    ytmsdy  
       2018-07-07 18:11:59 +08:00 via iPhone
    装个 pycharm 吧。。
    wsds
        10
    wsds  
    OP
       2018-07-07 18:13:39 +08:00
    @ytmsdy 有 pycharm, ctrl+alt+l 格式化了下,在 sublime 上仍是不符合
    BBCCBB
        11
    BBCCBB  
       2018-07-08 17:10:59 +08:00
    关掉 pep8 的验证,就不会有高亮了
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5014 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 09:46 · PVG 17:46 · LAX 02:46 · JFK 05:46
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.