小编Ero*_*mic的帖子

在 vim 中折叠特定的代码部分

我想知道是否可以在 vim 中仅自动折叠代码的特定部分(特别是对于 python 文件)。

我目前正在使用缩进折叠方法。如果标题与模式匹配,我只想折叠缩进的块。

例如,如果我在一个具有此函数的文件中,我希望所有以Example: 或References: 开头的块自动折叠,但我不希望折叠其他任何内容。

有没有一种简单的方法可以做到这一点?

def spawn_background_process(func, *args, **kwargs):
    """
    Run a function in the background
    (like rebuilding some costly data structure)

    References:
        http://stackoverflow.com/questions/2046603/is-it-possible-to-run-function-in-a-subprocess-without-threading-or-writing-a-se
        http://stackoverflow.com/questions/1196074/starting-a-background-process-in-python
        http://stackoverflow.com/questions/15063963/python-is-thread-still-running

    Args:
        func (function):

    CommandLine:
        python -m utool.util_parallel --test-spawn_background_process

    Example:
        >>> # DISABLE_DOCTEST
        >>> from utool.util_parallel import *  # NOQA
        >>> import utool as ut
        >>> import time
        >>> from os.path import join
        >>> # build test data
        >>> fname = 'test_bgfunc_output.txt'
        >>> dpath = ut.get_app_resource_dir('utool')
        >>> ut.ensuredir(dpath)
        >>> fpath …
Run Code Online (Sandbox Code Playgroud)

vim python

3
推荐指数
1
解决办法
117
查看次数

标签 统计

python ×1

vim ×1