Sublime Text 快速分别独立选中多行
效果图
直接上代码
import sublime, sublime_plugin
# 独立选择每一行(在当前选中范围内)
class SelectEverySingleLine(sublime_plugin.TextCommand):
def run(self, edit):
# self.view.run_command('select_all')
# for region in self.view.lines(sublime.Region(0, self.view.size())):
# self.view.selection.add(region)
lines = []
for region in self.view.sel():
for l in self.view.lines(region):
if l.a != l.b: # 忽略空行
lines.append(l)
# self.view.selection.add(l)
self.view.selection.clear()
for l in lines:
self.view.selection.add(l)
然后设置好快捷键
然后就可以玩耍了
- 选中你要编辑的文本(可以多段选择)
- ctrl/cmd + shift + a
- bingo!