【问题标题】:VScode Is there a way to fold code by a special comment prefix?VScode有没有办法通过特殊的注释前缀折叠代码?
【发布时间】:2023-02-24 06:14:18
【问题描述】:

我正在使用失控的 snakefile。我有点喜欢它是一个文件,但即使折叠了所有规则,我也必须处理一个长滚动条。 有没有一种方法/扩展允许代码通过特殊注释前缀折叠?

#% normalize data
rule count:
    ...
# some comment that should 
rule divide:
    ...
rule drop_duplicates:
    ...
#% statistical tests
rule ttest:
   ...
#% output
rule all:
    ...
rule zip:
    ...

这样我就可以把它折叠成:

#% normalize data
#% statistical tests
#% output

我认为这比处理多个文件更容易处理。

谢谢你,

尝试在线搜索,发现一个应该可以执行此操作但无法使其工作的扩展程序 (https://marketplace.visualstudio.com/items?itemName=zokugun.explicit-folding)。 如果有人想检查我尝试过的 zokugun 显式折叠规则:

{
    "workbench.colorTheme": "Default Dark+",
    "remote.SSH.remotePlatform": {
        "rocket": "linux",
        "Jovian": "linux",
        "JovianLocal": "linux"
    },
    "git.ignoreLegacyWarning": true,
    "cmake.configureOnOpen": true,
    "terminal.integrated.enableMultiLinePasteWarning": false,
    "audioCues.taskCompleted": "on",
    "audioCues.taskFailed": "on",
    "notebook.lineNumbers": "on",
    "window.zoomLevel": -1,
    "jupyter.askForKernelRestart": false,
    "[python]": {
        "explicitFolding.rules": [
            {
                "beginRegex": "#%%",
                "endRegex": "##%",
                "autofold": true
            },
            {
                "indentation": true,
                "offSide": true
            }
        ],
    "explicitFolding.autoFold": "1",
    },
    "explicitFolding.rules": [
    
    ],
}

【问题讨论】:

    标签: visual-studio-code


    【解决方案1】:

    你可以尝试这样做......

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-12-16
      • 2010-09-17
      • 2022-09-22
      • 2018-12-27
      • 2021-02-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多