21

It keeps bothering me that I cannot manage the Keyword for "One-click search engines". The keyword could be displayed as follows in Firefox 38.0.1 enter image description here

Through the help link, I found ways to add/hide/remove search engines. However, it did not give any suggestion on how to modify the search engine.

The practical motivation for me to learn how to change the keyword is that:

  1. Firefox cannot sync "search engines" across different installations. Only bookmarks and add-ons could be synced, so far.
  2. I am using Vimperator with Firefox, where pressing o (or t) followed by TAB, then keyword for search engine, will enable the finishing a search query sequence. Example:

    :open google happy 2015

will launch a Google result page searching for "happy 2015".

So, the syntax is: ":open keyword search-pattern".

Can anyone tell me how to change the "keyword" of a search engine? Or, give instruction on how to create a search engine of my own? (either on the web or locally loaded is fine.)

Brock Adams
  • 90,639
  • 22
  • 233
  • 295
llinfeng
  • 1,316
  • 1
  • 15
  • 39

3 Answers3

22

To edit the keyword for a search engine, double-click on the search engine's entry, or highlight it and press F2.

user551918
  • 336
  • 2
  • 4
  • 4
    I am not sure why this is not the best or selected answer. It is so un-obvious for any casual user that F2 would change the search engine entry to editable. – digitguy Mar 10 '17 at 19:09
  • This does *not* remove the default keyword; e.g. @bing for the MS search engine. – DrMoishe Pippik Feb 03 '21 at 19:18
  • first time I see this, I had the need to update this and I remember I did it somehow else, this would have been easierm i remember that to use google we just needed to type 'g searchterms' – arana Feb 10 '21 at 17:34
13

Solution in short, as kindly offered by Brandon Parmenter, goes as follows:

:bmark http://example.com/search#q=%s -keyword=example


Start of the longer/older answer

Though the solution inspired by the following link does not change the entries for search engine, it does offer a fully functional keyword feature.

wikiHow:How to Add a Custom Search Engine to Firefox's Search Bar

Unlike what has been suggested in the external link, no further add-on is needed. The following steps will complete the definition of a search-keyword:

  1. Go to the page on which one can search. (Either google.com, or github.com, or whatever)
  2. Right click the search box (through which one can type search inquiry) and select "Add a Keyword for this search"
  3. Define the keyword and press enter

This is not defining a search engine, but rather a search-keyword. Keywords defined in this way is stored as a Bookmarks entry.

So far, it is yet unclear how would conflicting keywords between search-engines-keywords and one we just defined should be resolved. Hopefully, since Firefox is syncing Bookmarks items, search-keyword may be synced to other installations.

Since the question to modifying the search-engine-keyword is yet unsolved, I will not accept my own answer.

Additionally, if one would be interested to look into the Bookmark entry, %s is the "place-holder" in the "Location" field of such bookmark that will be subsituted by whatever one would like to search.

llinfeng
  • 1,316
  • 1
  • 15
  • 39
  • @Noitidart, do you happen to know how to modify such keyword for *search engine* per se? Does the following site provide a valid solution? [mycroftproject](http://mycroftproject.com/submitos.html) I think am less experienced to verify on this. – llinfeng May 23 '15 at 01:23
  • Oh i didnt really read your solution, so you didnt figure out how to do it yet? Yep its easy have to use the Services.search component. You want to do it via addon right? Via manually it looks you posted solution for the manual method above? – Noitidart May 23 '15 at 01:41
  • @Noitidart: well, I offered a partial solution that does not touch the search engine. It is based on Bookmarks, which enabled the ability to sync for these "sudo" search engines. (As of now, settings regarding to search engine specification cannot be synced across installations of Firefox on various machines.) – llinfeng May 24 '15 at 01:42
  • +1 for `%s`! `:bmark http://example.com/search#q=%s -keyword=example` makes `:open example foo` operate like `:open http://example.com/search#q=foo`. :) – leftiness May 10 '16 at 18:51
  • @BrandonParmenter, this is cool! Yes, Vimperator does handle bookmarking through simply the command-line. Further, I guess (not tested yet) that sticking the clause into the _vimperator shall also do the trick. This makes zillions of search-engines at fingertips. [I am currently benefiting a lot from `scholar`, which is the shorthand for Google Scholar. The other sweat thing for Vimperator is that: typing out `sch` and hitting Tab completes the keyword for the bookmark. – llinfeng May 17 '16 at 22:39
2

To programatically change the keyword of a search engine you can do it like this:

var allEngines = Services.search.getEngines()
for (var i=0; i<allEngines.length; i++) {
    var currentEngine = allEngines[i];
    console.log('name of current engine:', currentEngine.name);
    var currentKeyword = currentEngine.alias; // is null if no current key word
}

To change the keyword programtically just set currentEngine.alias

Here is a variable viewer in browser console of allEngines you see its an array and each entry is like this, in this image here one entry is expanded:

If you know the name you can just get the engine by name with var currentEngine = Services.search.getEngineByName('Bing')

Noitidart
  • 35,443
  • 37
  • 154
  • 323