Search Anywhere Plugin

Download

An Updated version is now available at Sublime Plugins – Search Anywhere

This plugin is an improvement over Sublime Text 2 Search Stack Overflow where the user can now choose which search engine to use by default and per file type. This means that you could have all your .js files search on Stack Overflow, while all your .php files search on php.net and any other search on Google, for example.

All the commands are available through a simple set of menus in the Tools section or with the right click of the mouse. They are also all listed under Search Anywhere in the command palette.

For now, the supported search engines are Google, Stack Overflow, PHP.net, Bing and Yahoo. In the next version I will add a command to “suggest” a new search engine to be added.

Please do not hesitate to contact me with any question or feedback!

9 thoughts on “Search Anywhere Plugin

  1. Knud Potente says:

    Thank you for such a fantastic plug-in!

    Suggestion for search engines to be added in a future version:

    1) SitePoint:
    Publishes some of the best free, online – and searchable – generic reference guides for HTML, CSS and Javascript. It is possible to access the reference for a certain language construct (tag/function/etc.) using URLs such as:
    * http://reference.sitepoint.com/html/name-of-html-tag
    * http://reference.sitepoint.com/html/name-of-html-tag/name-of-tag-attribute
    * http://reference.sitepoint.com/html/name-of-css-property

    2) When Can I Use…?
    A thorough and constantly updated – and searchable – table of all HTML5 and CSS3 language extensions and additions, with a comprehensive description of the past, present and future state of support of each feature in each browser version. Searches can be made directly by using the following URL:
    * http://caniuse.com/#search=term (i.e., http://caniuse.com/#search=font-face)

    Once again, many thanks for such a great extension to Sublime Text!

  2. Eric says:

    Just added both, thanks for the suggestion, I didn’t know about these sites!

  3. Knud Potente says:

    Wow, you are so quick!

    Already upgraded my Search Anywhere plug-in! Thank you!!! 🙂

    One more suggestion:

    * MOZILLA DEVELOPER NETWORK (MDN)
    Has fantastic, up-to-date and thorough (community-driven) documentation for HTML, CSS and Javascript. Searches can be done via the URL, using the following syntax:

    https://developer.mozilla.org/en-US/search?q=term

    For instance:

    https://developer.mozilla.org/en-US/search?q=article (article element in HTML5)
    https://developer.mozilla.org/en-US/search?q=nth-child (nth-child CSS3 pseudo-class)
    https://developer.mozilla.org/en-US/search?q=Math.random (js global function)

    Once again, many thanks – and keep up the good work!

  4. Sheldon says:

    I’ve been using your plugin recently and I’m enjoying it! I have a few questions and suggestions…

    Is it possible to assign hotkeys to the various search commands? If so could you add instructions in the readme?

    The command “Search Anywhere: from Input (ask Search Engine)” doesn’t work for me, it first asks me the search engine and then gives the error:
    Traceback (most recent call last):
    File “./searchanywhere.py”, line 84, in on_select_done
    TypeError: GetSearchEngineEntry() takes exactly 1 argument (0 given)

    I’m using Ubuntu and ST2 build 2183.

    Suggestion: add Ruby and Ruby on Rails support
    Rails: http://api.rubyonrails.org/?q=term
    Ruby: http://www.ruby-doc.org (not sure how to format the search term)

    Suggestion: when there’s no selection and search by selection is chosen search the word that the cursor is currently on
    Suggestion: hide/remove/add search engines manually
    Suggestion: when searching from input provide search suggestions, e.g. for google use http://suggestqueries.google.com/complete/search?json&client=firefox&q=%q&hl=en (I’m not sure if this is possible with non-google engines but this would be a sweet feature!)

    Thanks!

  5. Eric says:

    Thanks for the feedback Sheldon!

    I fixed the Search from Input, I’m about to submit it on github. I also added the 2 search engines you suggested and your first suggestion. The management of the list of search engines will come at a later date.

    With the current API I have, it would be pretty hard to do something like search suggestions but as Jon keeps updating Sublime Text 2, I’ll keep an eye out for changes that might allow me to do it!

    As for keyboard shortcuts use Preferences -> Key Bindings (Default) as an example to add new entries in Preferences -> Key Bindings (User), and the available commands so far for the plugin are: search_anywhere_from_selection, search_anywhere_from_input, search_anywhere_select_default_search_engine, search_anywhere_select_search_engine_for_type, search_anywhere_from_selection_ask and search_anywhere_from_input_ask. I’m working on a site for the plugins where there will be detailed information for stuff like that.

    Cheers

  6. Sheldon says:

    Thanks Eric, it’s working great!

    One more suggestion: after invoking one of the commands that requires input, user should be able to press esc to cancel.

  7. Eric says:

    The “Esc” behavior is already working like that, at least on my version. What happens for you when you press Esc? Can you tell me your OS and Sublime Text version? It could help pin pointing the issue.

    Thanks!

  8. Paul says:

    One more search engine I’d suggest for inclusion: duckduckgo.com
    When searching with duckduckgo, you can include keywords like !github or !w3schools and it will redirect the search to that site, which would make choosing a search engine on the fly painless.
    https://duckduckgo.com/bang.html

  9. Branton says:

    Thanks so much for handy plugin!

    Here are the shortcuts I set up, in case anyone wants a starter:

    /** Search Anywhere shortcuts **/
    { “keys”: [“alt+s”], “command”: “search_anywhere_from_selection”},
    { “keys”: [“alt+shift+s”], “command”: “search_anywhere_from_selection_ask”},
    { “keys”: [“alt+i”], “command”: “search_anywhere_from_input”},
    { “keys”: [“alt+shift+i”], “command”: “search_anywhere_from_input_ask”},
    { “keys”: [“ctrl+alt+s”], “command”: “search_anywhere_select_default_search_engine”},
    { “keys”: [“ctrl+shift+s”], “command”: “search_anywhere_select_search_engine_for_type”}

Leave a Reply

Your email address will not be published. Required fields are marked *