首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >是否有一种方法来设置折叠符号中的亚英文版只读?

问是否有一种方法来设置折叠符号中的亚英文版只读?
EN

Stack Overflow用户
提问于 2017-01-04 09:56:46
回答 2查看 198关注 0票数 0

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

​

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-01-04 22:38:54

如果我理解你想要有这种行为,它会自动展开,如果你在折叠后面并按下后退空间。这很容易存档(在3125+版本中),您只需添加上下文和命令即可。

通过工具>> Developer >>新建插件创建插件.粘贴和保存:

代码语言:javascript
复制
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

将此添加到您的密钥映射中:

代码语言:javascript
复制
{
    "keys": ["backspace"],
    "command": "unfold_before",
    "context":
    [
        { "key": "selection_empty" },
        { "key": "is_behind_fold", "operator": "equal", "operand": true }
    ]
}

现在你应该没事了。

票数 3
EN

Stack Overflow用户

发布于 2017-01-04 10:02:53

只要打开折叠,任何定制的折叠都会消失。对于自定义折叠,我指的是插入CTRL + SHIFT + ]的折叠。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/41460907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档