有没有办法将 sublimetext 中的折叠符号设置为只读?

Is there a way to set the fold symbol in sublimetext read only?

如果我删除sublimetext中的折叠符号,整个折叠的文本会被删除吗? 我希望折叠符号在您删除它之前展开(如 vim)。

只需打开折叠,任何自定义折叠都会消失。对于自定义折叠,我的意思是使用 CTRL + SHIFT + ].

插入的折叠

如果我知道你想要这种行为,当你在折叠后面并按退格键时它会自动展开。这很容易归档(在版本 3125+ 中)你只需要添加一个上下文和一个命令。

通过工具 >> 开发人员 >> 新插件创建插件...,粘贴并保存:

import sublime
import sublime_plugin


class UnfoldBeforeCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        view = self.view
        for sel in view.sel():
            # fold the position before the selection
            view.unfold(sublime.Region(sel.b - 1))


class IsBehindFoldContext(sublime_plugin.EventListener):
    def on_query_context(self, view, key, operator, operand, match_all):
        if key != "is_behind_fold":
            return

        quantor = all if match_all else any

        result = quantor(
            view.is_folded(sel) and view.is_folded(sublime.Region(sel.b - 1))
            for sel in view.sel()
        )

        if operator == sublime.OP_EQUAL:
            result = result == operand
        elif operator == sublime.OP_NOT_EQUAL:
            result = result != operand
        else:
            raise Exception("Operator type not supported")

        return result

将此添加到您的键盘映射:

{
    "keys": ["backspace"],
    "command": "unfold_before",
    "context":
    [
        { "key": "selection_empty" },
        { "key": "is_behind_fold", "operator": "equal", "operand": true }
    ]
}

现在你应该没事了。