Outsearch with Firefox

This is a mini-article I wrote for the SitePoint Community Crier after a fellow staff member requested that I write some helpful tips for “next week’s Crier”. It’s just been published in Issue 64 and I’m simpy reproducing it here.

The SitePoint Community Crier is the newsletter of SitePoint Forums, and is put together by the Community Team lead by Saara Ord (Saz249). They do amazing work and I must say probably the most work among all the Teams (Programming, Design, Hosting, and Grow) just by producing the Crier alone. If you are not already subscribed, show them a bit of support by giving the Crier a go (subscribe at Newsletters page).

I’ll probably be writing more mini-articles for Firefox for the Crier, so if you have any suggestions on what I should cover, do write me or leave a comment. An even better idea would be to submit your own article to the Crier staff for publication - if you’re already a member of SitePoint Forums, just contact Saz249, or you can write me and I’ll set you up.

Now, on to the article…

Outfox, Outsearch with Firefox

Searching from address bar

Did you know that if you entered a search term into the address bar (where you’d normally enter a URL), Firefox does a “I’m Feeling Lucky” search on Google? If you don’t know what that means, try clicking the “I’m Feeling Lucky” search on Google the next time you’re there - basically, it takes you to the very first search result.

Granted, not many people would consider that very useful. I’d prefer to have it perform a normal Google search instead, as I’m sure quite a number of you would too. Not to fear, because with Firefox, you have control!

Let’s see how you can make Firefox perform a standard Google search from the address bar:

  1. Type in about:config in your Firefox address bar. It should open a page like this (click for a larger image):
    Screenshot of Firefox about:config page


  2. In the “Filter” textbox, enter “keyword.URL“. You should then see the keyword.URL preference with the value “http://www.google.com/search?btnI=I%27m+Feeling+Lucky&q=”. This is what makes it perform a “I’m Feeling Lucky” search.
  3. All we got to do, is to double-click that preference, and enter “http://www.google.com/search?btnG=Google+Search&q=” in the textbox of the dialog that comes up.
    Screenshot of keyword.URL preference dialog


  4. Hit “OK”, and you’re done! Try it out.

If Google doesn’t quite float your boat, you can use other search engines as well. Use “http://search.yahoo.com/search?p=” for a Yahoo! search, “http://imdb.com/find?q=” for a IMDB search, “http://dictionary.reference.com/search?q=” for a Dictionary.com search, and so on. You just have to make sure that the search string of your search facility accepts a query string that takes in your keyword(s).

Custom keywords

This is an amazingly powerful feature in Firefox. With custom keywords, you can load up a webpage using with your assigned keyword. For example, I can go to the SitePoint.com website by typing “sp” into the address bar. To achieve that, all I had to do was to create a bookmark for SitePoint.com (http://sitepoint.com/) and add the keyword “sp”.

“That’s it?”, you say. Well, we’re getting to it, the real power of custom keywords, that is. With custom keywords, I can Google search for the “best browser” by typing “g best browser” in the address bar, lookup the meaning of “promissory” on Dictionary.com by typing “d promissory”, and lookup the Bugzilla bug report for bug 75138 by typing “bug 75138″. Let’s work through how to do that with a Dictionary.com custom keyword search.

  1. Bookmark “http://dictionary.reference.com/search?q=%s”. “%s” is the placeholder that will be replaced by the word (or words) whose meaning you’re looking up.
  2. Give the bookmark a keyword as described above. I use “d”.
  3. Your bookmark properties should then look like this:
    Screenshot of bookmark properties and custom keyword field


  4. Click “OK” and now typing “d estoppel” in the address bar will load the Dictionary.com entry for “estoppel”.

Asa Dotzler has a good write-up on how to use custom keywords.

Ben Goodger has also created a Firefox extension called SmartSearch that adds a Smart Keyword menu in the context menu.

Context menu search

Another convenient feature that boosts your search productivity - searching from the right-click context menu. Select the words you want to search, right-click, then select Search Web for “keyword”. This will perform a search for your keyword on Google.

Screenshot of Firefox context menu search


Don’t like Google? Go to about:config in your Firefox address bar as described in the “Searching from address bar” section and look for the browser.search.defaulturl preference (its value should be “http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&q=”). You know what to do! (Hint: read the “Searching from address bar” section.)

Find as you type

Now that you’ve got some search results, you may want to search for occurences of your keyword in a long page. The “Find as you type” function is your savior. Just start typing the word (or words) that you want to find. Firefox will incrementally find and highlight the first instance of the word that matches what you type.

Screenshot of Find as you Type feature in action


Use F3 or Ctrl-G to do a “Find next”. No need to use the mouse, no need for an extra “Find” dialog that gets in the way! This is one of my favorite Firefox features (this is also in Opera) and I often lapse into simply typing to search for stuff in the occasions when I have to use IE!

Change the width of the search bar

The default search bar width is rather small, probably big enough for 20 characters. You can fix this if it bothers you by changing the width by editing your userChrome.css. The userChrome.css file is located in the “chrome” directory in your profile directory. The Firefox Help site has a page explaining how to get to your userChrome.css, if you’re not familiar with where your profile folder is. Once you have your userChrome.css, put this bit in there to set the width of the search bar to 350 pixels:

#search-container {
-moz-box-flex: 350 !important;
}

Upcoming search improvements in Firefox 0.9

Firefox 0.9 will come with more features that will improve your search productivity. You’ll be able to drag a bit of selected text into the search bar and perform a search on that text. Firefox 0.9 will also include an auto-complete delete feature where your autocomplete entries can be removed by doing a Shift-delete. Very useful for deleting something you don’t want someone else to come across, without having to clear out your entire history ;)

Another recently added feature is the ability to add smart keywords from form fields. No more messing around with “%s” thingies and what not!

These features have been available in nightly builds for quite some time now, so grab yourself a copy if you want them now. The Burning Edge maintains a watchlist of major bugfixes and regressions, and also links to custom builds (which are professionally packaged and come with processor-specific optimizations).

13 Comments & TrackBacks (Add yours)

The paper doll icon that precedes each comment is an idea conceived by Vanessa Tan.

Paper doll icon
miahz's Gravatar

Great article, but I have to point out something that is often mistaken. I’m not sure where it started [?], but almost everytime I’ve seen a tip about adjusting the width of the search bar, it is stated to set a pixel value for the -moz-box-flex property. -moz-box-flex does not define an absolute size in pixels or any other unit, but rather a relative weight or strength. The XUL Planet Element Reference (xulplanet.com seems to be down as I write this, but this mirror was working) states that the -moz-box-flex property:

Indicates the flexibility of the Style Properties. Flexible elements grow and shrink to fit their given space. The actual value is not relevant unless there are other flexible elements within the same container. Elements with larger flex values will grow more than elements with lower flex values, at the ratio determined by the two elements.

Check the size of the search container with the DOM Inspector, and I’ll bet it’s not 350 pixels. Furthermore, if you resize the browser window, or add/remove items on the toolbar, its size will change. If flex is not defined (which is the default for the search container) or the value is zero, the normal properties determine its size. Any arbitrary value greater than zero will cause the object to expand and fill available space, unless there is another object with the flex property–which happens to be the case on the Firefox toolbar. The “stronger” object with the greater value will take more space.

Giving the search container a flex value of 1 would cause it to flex (notice that it is not 1 pixel wide), but that is too weak to overcome the flex value of the urlbar container which is 1000 (also notice that removing the urlbar would allow the search bar to expand freely). So using the above value of 350 for the search bar container, the two will be proportioned by a ratio of 10:3.5. Set the search container’s flex to 1000, and it will evenly split available space with the urlbar container. If you actually want a 350 pixel wide search bar, then simply define a width value of 350px.

Posted by: miahz on April 23, 2004 10pm

Paper doll icon
Pankaj Narula's Gravatar

Amazing article. Thanks for sharing the info.

Pankaj

Posted by: Pankaj Narula on April 24, 2004 12am

Paper doll icon
adot's notblog*'s Gravatar

great search article
redemption in a blog has a really nice article on various Firefox searching techniques and modifications. It covers the basics of addressbar searching, custom keywords, context menu searching, and find as you type. Even if you’re familiar with those fe…

Posted by: adot's notblog* on April 24, 2004 5am

Paper doll icon
Stephen Ng's Gravatar

I used a lot of the features in the above article. I have customized my “Quick Searches” with MIT’s Start processor, stock quotes, amazon, etc.

I also use the “find as you type” feature very often. What I want to know is how to turn off the sound that Firefox produces when you are doing a “find as you type” for a search string that isn’t on the page. It’s awfulling annoying when you have the volume turned up loud.

Is it possible to turn the sound off in Firefox?!

Posted by: Stephen Ng on May 12, 2004 11am

Paper doll icon
Cheah Chu Yeow's Gravatar

Stephen: Yes, you can turn off the sound by going to about:config and looking for the ‘accessibility.typeaheadfind.enablesound’ preference. Set that to false and you’re set.

Posted by: Cheah Chu Yeow on May 12, 2004 2pm

Paper doll icon
B. Rintoul's Gravatar

You should try my extension for Google searching. I think it’s rather nice:

Posted by: B. Rintoul on May 26, 2004 11pm

Paper doll icon
purple's Gravatar

This is great info! I *knew* Mozilla is far more than I knew.

I just changed browser.search.defaulturl to do what I need most: translating the marked word.
Somehow it feels like a hack, because I can’t change the caption of “Search Web for”…
Therefore:
- Can I easily add another entry for the context menu of marked words?
or…
- Can I easily change the caption for the “Search Web for” context menu entry?

I know about Ben Goodgers SmartSearch, but that adds indiscriminately all quick searches and adds another menu level, both of which I don’t like…

Posted by: purple on June 19, 2004 12am

Paper doll icon
lowhero's Gravatar

Fantastic article! Does anyone know how to make Firefox automatically fill in a “http://www.” with a “.com” at the end when I type a word into the url bar. When I do it now, it does a search. IE does it with CTRL+Enter. Does Firefox have something like this??? Thxs.

Posted by: lowhero on July 2, 2004 2am

Paper doll icon
daniel bishop's Gravatar

CTRL + ENTER will do the same thing in Firefox.

Posted by: daniel bishop on July 3, 2004 12am

Paper doll icon
ruda's Gravatar

Can I do anything to get rid of the search bar? I feel the address bar is completely sufficient for making my searches when it is changed to do a full search instead of the ‘I am lucky’ search (I am usually not that lucky). The search bar then makes me feel that something is unnecessarily doubled, which I do not like. Thanks.

Posted by: ruda on August 31, 2004 12am

Paper doll icon
Cheah Chu Yeow's Gravatar

Yup sure you can! Right-click on the toolbar and choose “Customize…”. Drag the search bar into the panel that pops out and click “Done”. No more search bar!

Posted by: Cheah Chu Yeow on August 31, 2004 12am

Paper doll icon
alex's Gravatar

i am using firefox 1.0PR and when i try to change the width of the search bar all that happens is the width of the entire search bar is increased, however the input box is still limited to 16 or so characters. is there another property i need to set in userChrome for 1.0PR?
thanks.

Posted by: alex on October 8, 2004 1am

Paper doll icon
isaychew's Gravatar

wowowwww
thank you!
now my fox keeps silent while im searching
have a nice day

Posted by: isaychew on October 24, 2006 10pm

You can subscribe to the RSS feed for comments on this post.

Post a comment

(required)

(required, but never displayed)


You can format your comments using XHTML. Your email address will not be displayed or used for nefarious purposes.

Only following tags are allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>