Created
December 31, 2024 15:50
-
-
Save hyrious/e1c4e13e4223700c7fc05053b3518c3c to your computer and use it in GitHub Desktop.
Sublime Text fast navigate "//#region"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sublime, sublime_plugin | |
import re | |
class GotoRegion(sublime_plugin.TextCommand): | |
def is_enabled(self): | |
name = self.view.file_name() | |
return name.endswith('.js') or name.endswith('.ts') | |
def run(self, edit): | |
regions = self.view.find_all('//#region (.+)') | |
if w := self.view.window(): | |
self.regions = regions | |
w.show_quick_panel([self.view.substr(r) for r in regions], | |
lambda x: None, on_highlight=self.on_highlight) | |
def on_highlight(self, index): | |
r = self.regions[index] | |
self.view.sel().clear() | |
self.view.sel().add(r) | |
self.view.show(r) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment