Sublime Forum

Move cursor to click

#1

Hi,

I’m writing a plugin to automatically search open files with the alt+clicked word.

Current code:

import sublime, sublime_plugin

class QuickSearchCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        for region in self.view.sel():
            if region.empty():
                line = self.view.word(region)
                self.view.insert(edit, line.begin(), self.view.substr(line))
            else:
                self.view.insert(edit, region.begin(), self.view.substr(region))

This code grabs the word where the cursor was before the click, not the word you just clicked on. How would I move the cursor to the clicked word?

0 Likes

#2

I’ve actually decided to go a different route.

I’m going to activate search by grabbing the word the cursor is currently within, or based on the selection of the user, and then triggered by a shortcut.

0 Likes

#3

There is the package Open-Include, doing something like that with the shorcut ALT+D.
I’m interested into see some examples of what are you trying to open, and where these files are located.

0 Likes