Regex 升华文本2中Latex的特定语法块注释

Regex 升华文本2中Latex的特定语法块注释,regex,comments,latex,sublimetext2,code-snippets,Regex,Comments,Latex,Sublimetext2,Code Snippets,最近,我遇到了一篇文章,其中有一个优秀的脚本,可以在CSS的升华文本中继续一个块注释。将其添加到特定于环境的keybindings文件就像一个符咒。但是,当我尝试将其更改为与latex注释一起使用时,(即用*替换%),它不起作用 原始代码: {"keys": ["enter"], "command": "insert", "args" : {"characters": "\n * "}, "context": [ {"key": "selection_empty",

最近,我遇到了一篇文章,其中有一个优秀的脚本,可以在CSS的升华文本中继续一个块注释。将其添加到特定于环境的keybindings文件就像一个符咒。但是,当我尝试将其更改为与latex注释一起使用时,(即用*替换%),它不起作用

原始代码:

{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n * "}, 
"context": 
    [
        {"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
        "operand": "\\/\\*\\*$", "match_all": true}
    ]
},
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n* "}, 
"context": 
    [
        //{"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
        "operand": "^[\t ]*\\*[^\\/]", "match_all": true}
    ]
},
我的代码:

{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n % "}, 
"context": 
    [
        {"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
        "operand": "\\/\\%\\%$", "match_all": true}
    ]
},

{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n % "}, 
"context": 
    [
        //{"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
        "operand": "^[\t ]%\\%[^\\/]", "match_all": true}
    ]
},

好吧,我想做的有两个主要的缺陷。首先,我确实在正则表达式上犯了一个错误,替换了太多的*s。第二,原始代码是针对CSS的,它具有块注释样式

/*
*
*
*/
而我所选择的latex块注释的样式(不是内置的)是一个带有页眉和页脚的块,定义了注释的限制,并且维护了其中包含的文本,也会被注释,例如:

%%%%%%%%%%%% Comment Section Start %%%%%%%%%%%%
   %%%  Comments here
%%%%%%%%%%%% Comment Section Ends  %%%%%%%%%%%%
以下内容可用于latex,并可对其进行修改,使其与R等效,以便快速、一致地添加注释。我将它与添加页眉和页脚部分的代码片段一起使用

//
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n%%%\t"}, 
"context": 
    [
        {"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
         "operand": "\t*%%%.*$", "match_all": true}
    ]},

{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n%%%\t"}, 
"context": 
    [
        //{"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
          "operand": "\t*%%%", "match_all": true}
    ]},

谢谢你的宝贵意见

好吧,我想做的有两个主要缺陷。首先,我确实在正则表达式上犯了一个错误,替换了太多的*s。第二,原始代码是针对CSS的,它具有块注释样式

/*
*
*
*/
而我所选择的latex块注释的样式(不是内置的)是一个带有页眉和页脚的块,定义了注释的限制,并且维护了其中包含的文本,也会被注释,例如:

%%%%%%%%%%%% Comment Section Start %%%%%%%%%%%%
   %%%  Comments here
%%%%%%%%%%%% Comment Section Ends  %%%%%%%%%%%%
以下内容可用于latex,并可对其进行修改,使其与R等效,以便快速、一致地添加注释。我将它与添加页眉和页脚部分的代码片段一起使用

//
{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n%%%\t"}, 
"context": 
    [
        {"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
         "operand": "\t*%%%.*$", "match_all": true}
    ]},

{"keys": ["enter"], "command": "insert", "args" : {"characters": "\n%%%\t"}, 
"context": 
    [
        //{"key": "selection_empty", "operator": "equal", "operand": true},
        {"key": "preceding_text", "operator": "regex_contains", 
          "operand": "\t*%%%", "match_all": true}
    ]},

谢谢你的宝贵意见

定义
不起作用
。还请注意,
*
是量词,表示
与前面的标记零次或多次匹配
。它也很模糊,我的意思是这个脚本应该做什么。您能提供这两种情况的一些输入吗?它应该在块注释部分的每一行中添加%,也就是说,它检查是否有注释字符(*在css中,%在latex中)。我所说的不起作用,是指它没有任何作用。然而,第一个添加了*。latex中的注释是什么?是
/%这是一条评论%/
?您更改了一条
*
,太多了:
^[\t]*\\%[^\\\/]
,或者只是
^[\t]*%[^\\/]
(因为正如哈姆扎所说,第一条
*
是一个量词)。然而,LaTeX没有块注释这样的东西,是吗(除非您自己定义它)。当前,代码段仍然希望块注释以
/%
开头,这并没有真正的帮助。定义
不起作用。还请注意,
*
是量词,表示
与前面的标记零次或多次匹配
。它也很模糊,我的意思是这个脚本应该做什么。您能提供这两种情况的一些输入吗?它应该在块注释部分的每一行中添加%,也就是说,它检查是否有注释字符(*在css中,%在latex中)。我所说的不起作用,是指它没有任何作用。然而,第一个添加了*。latex中的注释是什么?是
/%这是一条评论%/
?您更改了一条
*
,太多了:
^[\t]*\\%[^\\\/]
,或者只是
^[\t]*%[^\\/]
(因为正如哈姆扎所说,第一条
*
是一个量词)。然而,LaTeX没有块注释这样的东西,是吗(除非您自己定义它)。目前,代码段仍然希望块注释以
/%%
开头,这并没有真正的帮助。