June 13, 2007

Shortcut Searches

Firefox bookmarks have a few features that can save you a lot of time, if used to their full potential. For starters, each bookmark can have an associated keyword, which, when typed in the location bar, loads the bookmarked page. For example, if your bookmark to websudoku.com has the keyword sudoku, you can type <Ctrl-L>sudoku<Enter> and attempt to solve a sudoku.

Ok, so that's not so great. I'm all for keyboard shortcuts, but mousing to that bookmark is almost as fast. But wait, there's more! If you put the string %s in your bookmark, it will be replaced by anything you type after the keyword. So a bookmark google.com/search?q=%s, with keyword g, will let you type <Ctrl-L>g optimus<Enter> to find out how much you'd have to spend to get the ultimate keyboard. That's significantly faster, mostly because you don't have to load the search page, just the results. You can get this same savings by using Firefox's search box, but it's much faster to choose a search engine by typing a keyword instead of picking it from the menu by mouse.

Choosing short, memorable keywords is important. You want to Huffman code them, so that your most frequently used searches have the shortest keywords. Some of mine:Because you have full control of these search bookmarks, you can customize them to your heart's content. For example, you can make Google return 20 results per page instead of 10: google.com/search?num=20&q=%s. (Useful for people who discard all cookies at the end of a browsing session, and therefore can't save preferences for long.)

More importantly, you can add things to the search string. I use the keyword m for Google Maps. Since Google doesn't know I live in Toronto, entering a street address without specifing a city causes problems. So I also have the keyword mt for "Maps Toronto", maps.google.com/maps?q=%s%2C%20Toronto, which appends ", Toronto" to the address I type or, more likely, paste into the location bar.

You can take this technique a long way. I have one bookmark, keyword cia, that uses Google's "I'm feeling lucky" feature to search the subdirectory of the CIA World Factbook the country profiles are served from. So I can type <Ctrl-L>cia canada<Enter> to look up the latest estimate of Canada's population and GDP.

The %s replacement isn't perfect. Most notably, when the user doesn't type anything after the keyword, the %s isn't removed, which can lead to some strange search results or even 400 Bad Request errors. To deal with this, you can introduce javascript into your bookmarks to send you to the search page if you don't enter anything and to search results if you do.

Bookmarklets, bookmarks that execute javascript, can do some amazing things, but they don't have an easy way to get user input. Combining them with keywords and %s allows you to do some neat things. The most useful one I've created so far is a site search, which uses Google to search the domain you're currently browsing.

You can look at my shortcut bookmarks here, and import them into Firefox if you want to try them out yourself. (You'll have to use a text editor to remove the geocities server generated crud at the bottom of the file (clearly marked). Sorry about that.)


Post a Comment

<< Home