一、新建 remove_comments.py 文件
将下面的 Python 代码保存到 Packages/User 目录下(可以通过点击 Preferences -> Browse Packages 进入 Packages 目录,然后再进入 User 目录),并命名为 remove_comments.py。
import sublime_plugin
class RemoveCommentsCommand(sublime_plugin.TextCommand):
def run(self, edit):
comments = self.view.find_by_selector('comment')
for region in reversed(comments):
self.view.erase(edit, region)
二、输入命令执行
Windows 可以使用快捷键 Ctrl`呼出控制台。
OSX 可以使用快捷键 Control + 呼出控制台,也可以点击 View -> Show Console呼出控制台。
然后输入下面这行命令,再回车就行。
view.run_command('remove_comments')
三 绑定快捷键
Preferences ==> Key Bindings
添加:
{ "keys": ["ctrl+alt+shift+d"], "command": "remove_comments" },