Thanks this works great. This was the one thing that I really needed this editor to do. Great for working with log files.
Only had to fix the indenting. Thanks so much!!
Edit: Here is my contribution. the “all_toggle” command. You can bind it, and once you perform your all command you can easily toggle back and forth between showing all lines and showing the result of all
[code]import sublime, sublime_plugin
class AllCommand(sublime_plugin.TextCommand):
def done(self,arg):
self.foldstr = arg
self.all()
def all(self):
view = self.view
view.run_command("unfold_all")
endline, endcol = view.rowcol(view.size())
line = 0
firstRegion = None
currRegion = None
regions = ]
while line < endline:
region = view.full_line(view.text_point(line, 0))
data = view.substr(region)
if data.find(self.foldstr) == -1:
if firstRegion == None:
firstRegion = region
lastRegion = region
else:
lastRegion = region
else:
if firstRegion:
currRegion = firstRegion.cover(lastRegion)
regions.append(currRegion)
firstRegion = None
line += 1
if currRegion:
regions.append(currRegion)
currRegion = None
if firstRegion:
currRegion = firstRegion.cover(lastRegion)
regions.append(currRegion)
firstRegion = None
view.fold(regions)
view.settings().set("all", self.foldstr)
def run(self, edit):
if self.view.settings().has("all"):
self.done(self.view.settings().get("all"))
return
window = self.view.window()
for reg in self.view.sel():
defstr = self.view.substr(reg)
break
window.show_input_panel("Show Only Lines Containing",defstr,self.done,None,None)
class AllToggleCommand(sublime_plugin.TextCommand):
def run(self, edit):
view = self.view
if view.settings().has(“all”):
if len(view.folded_regions()):
view.run_command(“unfold_all”)
else:
view.run_command(“all”) [/code]