Skip to content

Instantly share code, notes, and snippets.

@chitchcock
Created September 6, 2012 14:12
Show Gist options
  • Save chitchcock/3656680 to your computer and use it in GitHub Desktop.
Save chitchcock/3656680 to your computer and use it in GitHub Desktop.
Sublime Text 2 Plugin to search for decimal values using a hex value
import sublime, sublime_plugin
class SearchHexCommand(sublime_plugin.TextCommand):
def findHexInView(self, pcode):
intToFind = int(pcode, 16)
print('Looking for ' + str(intToFind))
self.markers = []
self.foundRegions = []
self.foundRegions = self.view.find_all('(' + str(intToFind) + ')', 0, '$1', self.markers)
if self.foundRegions != None:
print (self.foundRegions)
self.view.window().show_quick_panel(self.markers, self.gotoMarker, sublime.MONOSPACE_FONT)
def gotoMarker(self, choice):
if choice == -1:
return
self.view.show(self.foundRegions[choice])
def run(self, edit):
self.view.window().show_input_panel('Enter Hex Value To Find', '', self.findHexInView, None, None)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment