Sublime快速删除注释内容

Sublime找中文

[\x{4e00}-\x{9fa5}]

Sublime删除注释内容

利用Sublime自带的语法高亮, 对注释进行识别, 进而删除

Preferences ==> Browse 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)

Ctrl+` 呼出控制台, 输入命令:

view.run_command('remove_comments')

绑定快捷键

Preferences ==> Key Bindings
添加:

{ "keys": ["ctrl+alt+shift+d"], "command": "remove_comments" },
posted @ 2021-03-31 12:46  Jrri  阅读(560)  评论(0编辑  收藏  举报