Home Download Buy Blog Forum Support

How to work with selection?

How to work with selection?

Postby zero on Thu Oct 10, 2013 5:16 am

There is view.sel() but I can't figure out how to use it. Using the following codes as example, how do you make it work only in selection of text?

Code: Select all
class FoobarCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        str = self.view.find_all(" foo ")
        for r in str:
            self.view.erase(edit, r)
Posts: 1
Joined: Thu Oct 10, 2013 4:58 am

Re: How to work with selection?

Postby sapphirehamster on Thu Oct 10, 2013 8:16 pm

It's difficult to understand what you are asking. Are you asking how to restrict your find_all searches to selected text? If so, you could just check if each region from find_all is within view.sel() (using the contains method).
Posts: 99
Joined: Sun Jul 01, 2012 11:19 pm

Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 3 guests