Sublime Forum

Jump to a line in a file from "Go to Anything"

#1

Hi, I’d like to change the “go to anything” functionality to accept a different way to get to a line in a file.

For example, if I type in the “Go to Anything” dialog “DashboardPage.php on line 195” - I want to get to line 195 on DashboardPage.php

I know the original syntax is “DashboardPage.php:195”, but it would be great to overwrite that for me.

Is this achievable via configuration or plugin? I looked into some of the API, in particular the sublime_plugin.EventListener but could not find a way to hook this functionality.

Thanks

0 Likes

#2

It is possible to write an plugin that works so. And you can bind the command-call to the default hotkey.
But one question:
Why do you want to type more characters than needed?
I don’t understand the sense behind this.

0 Likes

#3

[quote] But one question:
Why do you want to type more characters than needed?
[/quote]

That’s a good question, I see the pattern “DashboardPage.php on line 195” very often in the error logs on my application, when I copy and paste it to Sublime I have to remove the " on line " each time, would be good if that was automatically, also I wanted to know more about building a simple plugin for sublime so thought this would be a good chance to learn.

Can you explain how I would start binding the command-call to the default hotkey? As I mentioned I have looked at sublimetext.com/docs/3/api_reference.html though the sublime_plugin.EventListener does not seem to handle what I asked.

Thanks

0 Likes

#4

This is something similar:
github.com/bizoo/GotoSelection/ … lection.py
Take a look at it and ask if you don’t understand something.

Note that pasting a text containing : or @ in the Go to Anything edit doesn’t always works well, it depend of the first result from ST search.

0 Likes

#5

Thanks for the reply.

In this plugin you are finding the text from the selection, which is what you wanted. One question I have now is how I do get the text that has been inserted in the “show_overlay”?

0 Likes