加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

使用Vim的Python代码折叠

发布时间:2020-12-16 01:29:41 所属栏目:安全 来源:网络整理
导读:我已经尝试了一堆 Python代码折叠插件,我已经看到这个问题一个 here,但它们似乎并不太有用,以这种方式实现Python代码折叠: class myClass(models.Model): [folded code] class Meta: [folded code] def __unicode__(self): [folded code] def save(self,*ar
我已经尝试了一堆 Python代码折叠插件,我已经看到这个问题一个 here,但它们似乎并不太有用,以这种方式实现Python代码折叠:
class myClass(models.Model):
    [folded code]

    class Meta:
        [folded code]

    def __unicode__(self):
        [folded code]

    def save(self,*args,**kwargs):
        [folded code]

所以我的问题是,有没有任何Python代码折叠插件可以做到这一点?我迄今没有找到任何东西,而且我已经尝试了很多这样的Vim插件.

description

Because of its reliance on significant whitespace rather than explicit block delimiters,properly folding Python code can be tricky. The Python syntax definition that comes bundled with Vim doesn’t contain any fold directives at all,and the simplest workaround is to :set foldmethod=indent,which usually ends up folding a lot more than you really want it to.

There’s no shortage of Vim plugins for improved Python folding,but most seem to suffer from cobbled-together algorithms with bizarre,intractable bugs in the corner cases. SimpylFold aims to be exactly what its name suggests: simple,correct folding for Python. It’s nothing more than it needs to be: it properly folds class and function/method definitions,and leaves your loops and conditional blocks untouched. There’s no BS involved: no screwing around with unrelated options (which several of the other plugins do),no choice of algorithms to scratch your head over (because there’s only one that’s correct); it just works,simply.

http://www.vim.org/scripts/script.php?script_id=3723

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读