我对sublime文本很新,但是想要进行键绑定以将光标移动到特定/常量列,而不管以前输入的任何文本。这将用于向最右侧的代码添加注释,或仅用于改进编码verilog(或其他语言)的一致性。
基本上在任何输入的文本之后,点击ctrl + 1(或任何其他键绑定),光标将转到指定的列,添加空格作为填充。
这是我到目前为止所拥有的。
[{ "keys": ["ctrl+1"],
"command": "run_multiple_commands",
"args": {
"commands": [
{ "command": "move_to", "args": {"to": "eol", "extend": false} },
{ "command": "insert", "args": {"characters": " "} },
{ "command": "insert_snippet", "args": {"contents": "$TM_LINE_INDEX"} },
{ "command": "move", "args": {"by": "words", "forward": false} },
{ "command": "insert", "args": {"characters": "\t\t\t\t"},"context":
[
{ "key": "following_text", "operator": "regex_match", "operand": "40", "match_all": true }
]
},
{ "command": "insert", "args": {"characters": "\t\t\t"},"context":
[
{ "key": "following_text", "operator": "regex_match", "operand": "41", "match_all": true }
]
},
{ "command": "delete_word", "args": { "forward": true } }
]
}
}]
我设置代码的方式是(步骤3不工作):
尝试使用正则表达式根据标签/空格的数量添加。我只添加了两种情况,但是对于各种光标列_#(位置),而不仅仅是光标列位置40和41,会重复这种情况。下面是非工作代码块。
{ "command": "insert", "args": {"characters": "\t\t\t\t"},"context":
[
{ "key": "following_text", "operator": "regex_match", "operand": "40", "match_all": true }
]
},
{ "command": "insert", "args": {"characters": "\t\t\t"},"context":
[
{ "key": "following_text", "operator": "regex_match", "operand": "41", "match_all": true }
]
},
提前感谢您的任何帮助或评论。