在 Sublime Text 2 中注释 last/first 行文件
Comment last/first line of file in Sublime Text 2
我想要一个快捷键来注释掉文件的第一行和最后三行。
我怎样才能做到这一点?
谢谢。
我会看看 this。我只会导航到一行,插入注释字符,导航到另一行,插入注释...等等
祝你好运。
您可以创建一个宏,例如 Packages/User/comment_first_last.sublime-macro
:
[
{"command": "move_to", "args": {"to": "bof", "extend": false}},
{"command": "insert", "args": {"characters": "# "}},
{"command": "move_to", "args": {"to": "eof", "extend": false}},
{"command": "move_to", "args": {"to": "bol", "extend": false}},
{"command": "insert", "args": {"characters": "# "}},
{"command": "move", "args": {"by": "lines", "lines": true, "forward": false}},
{"command": "move_to", "args": {"to": "bol", "extend": false}},
{"command": "insert", "args": {"characters": "# "}},
{"command": "move", "args": {"by": "lines", "lines": true, "forward": false}},
{"command": "move_to", "args": {"to": "bol", "extend": false}},
{"command": "insert", "args": {"characters": "# "}}
]
然后在Preferences -> Key Bindings - User
中创建一个键映射:
{ "keys": ["ctrl+shift+i"], "command": "run_macro_file", "args": {"file": "Packages/User/comment_first_last.sublime-macro"}}
所以你有一个文件
按ctrl+shift+i触发宏:
您可能希望将宏文件中的 #
字符更改为您的注释字符。
我想要一个快捷键来注释掉文件的第一行和最后三行。
我怎样才能做到这一点?
谢谢。
我会看看 this。我只会导航到一行,插入注释字符,导航到另一行,插入注释...等等
祝你好运。
您可以创建一个宏,例如 Packages/User/comment_first_last.sublime-macro
:
[
{"command": "move_to", "args": {"to": "bof", "extend": false}},
{"command": "insert", "args": {"characters": "# "}},
{"command": "move_to", "args": {"to": "eof", "extend": false}},
{"command": "move_to", "args": {"to": "bol", "extend": false}},
{"command": "insert", "args": {"characters": "# "}},
{"command": "move", "args": {"by": "lines", "lines": true, "forward": false}},
{"command": "move_to", "args": {"to": "bol", "extend": false}},
{"command": "insert", "args": {"characters": "# "}},
{"command": "move", "args": {"by": "lines", "lines": true, "forward": false}},
{"command": "move_to", "args": {"to": "bol", "extend": false}},
{"command": "insert", "args": {"characters": "# "}}
]
然后在Preferences -> Key Bindings - User
中创建一个键映射:
{ "keys": ["ctrl+shift+i"], "command": "run_macro_file", "args": {"file": "Packages/User/comment_first_last.sublime-macro"}}
所以你有一个文件
按ctrl+shift+i触发宏:
您可能希望将宏文件中的 #
字符更改为您的注释字符。