-3

How can I create a selection?

Oktay Acikalin 14 year бұрын жаңартылды 14 year бұрын 2
I've written a plugin which replaces the selected regions with some other content. Now I would like to reselect the results to show the user what has been replaced. How can I do this?
You can use view.sel().add(sublime.Region(x, y)) to add a region to the selection. The functions on the selection ('RegionSet'), haven't changed apart from case from Sublime Text 1, so you can reference the API docs for the other functions on view.sel().

In this case though, you may be better off using view.replace(region, string), which will replace the region, but preserve any selection at that region.
I already do view.replace() but this cancels the selection. I'm now collecting all regions and do this at the end which works nicely:
[self.view.sel().add(region) for region in regions]

Thanks a lot!

PS You can get it from here: http://www.sublimetext.com/forum/viewtopic.php?f=5&t=1609 ;)