Using keyword searches: Difference between revisions

From MozillaZine Knowledge Base
Jump to navigationJump to search
(External links added and Quick Searches location clarification)
(Add Bookmark Here ² extension)
 
(16 intermediate revisions by 8 users not shown)
Line 1: Line 1:
[[Category:Location Bar]]
{{appliesto2|Firefox|Mozilla Suite|Searches}}
{{appliesto2|Firefox|Mozilla Suite|Searches}}
:{{mergefrom}} [[Firefox : Tips : Quick searches]]
In Firefox and Mozilla Suite you can specify keywords for bookmarks by filling in the &ldquo;Keyword&rdquo; field in the bookmark&rsquo;s Properties. When you type the keyword into the [[:Category:Location Bar|Location Bar]] and hit <tt>[Enter]</tt>, the keyword will be replaced with the bookmarked URL. For example, bookmarking http://google.com/, giving it a keyword of &ldquo;<tt>g</tt>&rdquo;, and typing &ldquo;<tt>g</tt>&rdquo; into the Location Bar will take you to Google.


In Firefox and Mozilla Suite you can specify keywords for bookmarks. When you type the keyword into the Location Bar and hit Enter, the keyword will be replaced with the bookmarked URL. For example, bookmarking http://google.com/, giving it a keyword of "google", and typing "google" into the Location Bar will take you to Google.
What makes keywords very powerful is that if you add a &ldquo;<tt>%s</tt>&rdquo; at some place in your bookmark&rsquo;s URL, it will be replaced by the words you type in after the keyword. (These are sometimes called &ldquo;Quicksearches&rdquo;.) For example, if we were to modify the bookmark mentioned above so that it pointed to &ldquo;<tt>http://google.com/?q=%s</tt>&rdquo;, we can type &ldquo;<tt>g mozilla</tt>&rdquo; into the Location Bar to arrive at &ldquo;<tt>http://google.com/search?q=mozilla</tt>&rdquo;.


What makes keywords very powerful is that if you add a "%s" at some place in your bookmark URL, that will be replaced by the words you type in after your keywords. For example, a keyword of "google" corresponding to "http://google.com/?q=%s" and typing in "google mozilla" into the Location Bar will give you "http://google.com/search?q=mozilla".
==Default searches==
By default, Mozilla Firefox comes with several bookmarks with keywords defined. They&rsquo;re located in the &ldquo;Quick Searches&rdquo; folder in the default bookmarks.


==Creating Bookmarks with Keywords==
{| {{prettytable}}
* Search for a random string, say, "mozilla".
|-
* Bookmark the resulting page, then open the bookmark's properties and replace the search term with '''%s'''.
! Bookmark Name
! Keyword
! Bookmark URL
|-
| Google Quicksearch
| <tt>google</tt>
| http://www.google.com/search?q=%s
|-
| Dictionary.com Quicksearch
| <tt>dict</tt>
| http://dictionary.reference.com/search?q=%s
|-
| Stock Symbol Quicksearch
| <tt>quote</tt>
| http://www.google.com/search?q=stocks:%s
|-
| Wikipedia Quicksearch
| <tt>wp</tt>
| http://en.wikipedia.org/wiki/Special:Search?search=%s
|-
| Urban Dictionary
| <tt>slang</tt>
| http://www.urbandictionary.com/define.php?term=%s
|}


For example, Google. The search URL for their database is "http://google.com/search?q=" where any words typed after the "q=" will be used in the search. This part is where we want to add text so we place a "%s" after the "q=" when writing the location. This makes the bookmark's URL look like "http://google.com/search?q=%s". Default sites in Firefox are located under the Quick Searches section of Bookmarks.
Firefox no longer supplies a set of default keyword shortcuts, though many people may have started with the above. You can easily add your own keyword shortcuts, such as one to search the MozillaZine Knowledge Base.  You need not limit yourself to letters alone, which might be mistaken for search words.  Also a keyword of "g:" would be a lot faster to type than the suggestion above of "google".


A keyword of "google" is assigned to the bookmark. To recap:
{| {{prettytable}}
|-
! Bookmark Name
! Keyword
! Bookmark URL
|-
| MozillaZine KB
|  <tt>::</tt>
| http://www.google.com/search?num=100&hl=en&newwindow=1&q=site%3Akb.mozillazine.org+-intitle%3Atalk+-inurl:%22/index.php?title=%22+-inurl%3A%22%2Findex.php%3Ftitle%3D%22+%S&btnG=Search
|}


: '''Name''': Google<br>
==Creating bookmarks with keywords==
: '''Location''': http://google.com/search?q=%s<br>
In Mozilla Firefox, you can simply right-click in a search field on a web page and choose &ldquo;Add a Keyword for this Search.&rdquo; This will pop up a dialog for you to add a bookmark name and keyword.
: '''Keyword''': google


Now, typing "google mozilla" in the Location Bar will take you to a Google search about Mozilla.
You can also create it manually:
# Do a search on the site you want to add a quicksearch to.
# Bookmark the page you are brought to (the results page).
# Open the Properties dialog for your new bookmark.
# In your bookmark&rsquo;s URL (the Location field), find and replace what you searched for with <tt>%s</tt> (If it does not appear, you cannot use a quicksearch here)
# Add a keyword


''Note: Mozilla Suite users can use the "Bookmarks -> File Bookmark..." feature and edit bookmark's properties at the moment of its creation.''
Difference between (small s) <tt>%s</tt> and (Capital S) <tt>%S</tt>
# (small s):  <tt>%s</tt> will have additional substitution replacements: <tt>#</tt> by <tt>%23</tt>,  <tt>%</tt> by <tt>%25</tt>,  <tt>/</tt> by <tt>%2F</tt>,  and <tt>@</tt> by <tt>%40</tt>.
# (Capital S):  <tt>%S</tt> will not have substitutions and allow use of  <tt>C++</tt> in a Google search,  allow use of  <tt>@</tt> in an email substitution, allow use of a fragment-id in a url substitution <tt>index.html#example2</tt>, and use of a directory as in <tt>code/example2.txt</tt>.


==See Also==
''Note: Mozilla Suite users can use the &ldquo;Bookmarks &rarr; File Bookmark...&rdquo; feature and edit bookmark&rsquo;s properties at the moment of its creation.''
 
''Note: Firefox users with [https://addons.mozilla.org/firefox/addon/3880/ Add Bookmark Here ²] extension, or the older  [https://addons.mozilla.org/firefox/42 Open Book] extension, can create a bookmark and add keyword property at the same time.  An alternative is [http://userstyles.org/styles/9029 Keyword addition for Add/Change Bookmark (Fx3) | userstyles.org]  as a style used with the [https://addons.mozilla.org/firefox/2108 Stylish]  extension that can be customized. ''
 
==Specifying a non-UTF-8 encoding in the query==
By default, <tt>%s</tt>-replaced query terms are sent to the server in UTF-8 encoding. Some servers, however, use other encoding in their query string, especially in the non-Western environment to result in misinterpreted or garbled query. The <tt>mozcharset=</tt> parameter has been introduced to work around this problem in [https://bugzilla.mozilla.org/show_bug.cgi?id=258223 Bug 258223].
 
For example, [http://word.tta.or.kr/terms/terms.jsp Korean computer jargon dictionary] uses EUC-KR encoding. Normal keyword search such as,
 
<tt>http://word.tta.or.kr/terms/terms.jsp?search=%s</tt>
 
produces incorrect result when supplied with non-ASCII query term <tt>파일</tt>. By appending <tt>mozcharset=<em>charset</em></tt> parameter, as in
 
<tt>http://word.tta.or.kr/terms/terms.jsp?search=%s'''&mozcharset=EUC-KR'''</tt>
 
users are directed to the correct result page.
 
'''Caveat:''' <tt>mozcharset=<em>charset</em></tt> parameter should be '''appended at the end''' of the query string with the preceding '''&'''.
 
==See also==
* [[List of keyword searches]]
* [[List of keyword searches]]
* [[Multiple parameter keyword searches]]
* [[Multiple parameter keyword searches]]
* [[Location Bar Search]]
* [http://forums.mozillazine.org/viewtopic.php?t=333466 Tweaking the keyword search to open another page when no search terms specified]
* [http://forums.mozillazine.org/viewtopic.php?t=334850 Search multiple engines with a single keyword search]
==External links==
* [http://www.mozilla.org/docs/end-user/keywords.html How Cool are Custom Keywords?] by Asa Dotzler.
* [http://www.mozilla.org/docs/end-user/keywords.html How Cool are Custom Keywords?] by Asa Dotzler.
* [http://www.mozilla.org/products/firefox/smart-keywords Smart Keywords]
* [http://www.wormus.com/leakytap/Internet/CustomKeywords/ CustomKeywords] (Leaky Tap Wiki) with other links, as well
* Customizing [[Location Bar Search]]
* [http://www.mvps.org/dmcritchie/firefox/kws.htm Firefox Keyword Shortcuts] by David McRitchie, includes usage tips
* [http://johnbokma.com/firefox/keymarks-explained.html Firefox smart keywords explained] by John Bokma, includes screenshots
* [http://twofoos.org/content/quicksearches/ Quicksearches -- Samples and Instructions] by Chris Poverk, creator of the related SmartSearch extension
* [http://docs.blacktree.com/quicksilver/quicksilver Quicksilver] provides access to Mozilla suite/Firefox keyword searches globally (from within any application)--for Mac OS X
* [http://support.mozilla.com/kb/Smart+keywords Smart keywords] (Mozilla Support)


==External links==
* [[https://addons.mozilla.org/firefox/5663 keywordManager]] extension to manage bookmark keywords
*[http://johnbokma.com/firefox/keymarks-explained.html Firefox smart keywords explained] includes screenshots
*[http://www.wormus.com/leakytap/Internet/CustomKeywords/ CustomKeywords] with other links, as well

Latest revision as of 11:37, 17 September 2010

This article applies to Firefox and Mozilla Suite.

In Firefox and Mozilla Suite you can specify keywords for bookmarks by filling in the “Keyword” field in the bookmark’s Properties. When you type the keyword into the Location Bar and hit [Enter], the keyword will be replaced with the bookmarked URL. For example, bookmarking http://google.com/, giving it a keyword of “g”, and typing “g” into the Location Bar will take you to Google.

What makes keywords very powerful is that if you add a “%s” at some place in your bookmark’s URL, it will be replaced by the words you type in after the keyword. (These are sometimes called “Quicksearches”.) For example, if we were to modify the bookmark mentioned above so that it pointed to “http://google.com/?q=%s”, we can type “g mozilla” into the Location Bar to arrive at “http://google.com/search?q=mozilla”.

Default searches

By default, Mozilla Firefox comes with several bookmarks with keywords defined. They’re located in the “Quick Searches” folder in the default bookmarks.

Bookmark Name Keyword Bookmark URL
Google Quicksearch google http://www.google.com/search?q=%s
Dictionary.com Quicksearch dict http://dictionary.reference.com/search?q=%s
Stock Symbol Quicksearch quote http://www.google.com/search?q=stocks:%s
Wikipedia Quicksearch wp http://en.wikipedia.org/wiki/Special:Search?search=%s
Urban Dictionary slang http://www.urbandictionary.com/define.php?term=%s

Firefox no longer supplies a set of default keyword shortcuts, though many people may have started with the above. You can easily add your own keyword shortcuts, such as one to search the MozillaZine Knowledge Base. You need not limit yourself to letters alone, which might be mistaken for search words. Also a keyword of "g:" would be a lot faster to type than the suggestion above of "google".

Bookmark Name Keyword Bookmark URL
MozillaZine KB :: http://www.google.com/search?num=100&hl=en&newwindow=1&q=site%3Akb.mozillazine.org+-intitle%3Atalk+-inurl:%22/index.php?title=%22+-inurl%3A%22%2Findex.php%3Ftitle%3D%22+%S&btnG=Search

Creating bookmarks with keywords

In Mozilla Firefox, you can simply right-click in a search field on a web page and choose “Add a Keyword for this Search.” This will pop up a dialog for you to add a bookmark name and keyword.

You can also create it manually:

  1. Do a search on the site you want to add a quicksearch to.
  2. Bookmark the page you are brought to (the results page).
  3. Open the Properties dialog for your new bookmark.
  4. In your bookmark’s URL (the Location field), find and replace what you searched for with %s (If it does not appear, you cannot use a quicksearch here)
  5. Add a keyword

Difference between (small s) %s and (Capital S) %S

  1. (small s): %s will have additional substitution replacements: # by %23, % by %25, / by %2F, and @ by %40.
  2. (Capital S): %S will not have substitutions and allow use of C++ in a Google search, allow use of @ in an email substitution, allow use of a fragment-id in a url substitution index.html#example2, and use of a directory as in code/example2.txt.

Note: Mozilla Suite users can use the “Bookmarks → File Bookmark...” feature and edit bookmark’s properties at the moment of its creation.

Note: Firefox users with Add Bookmark Here ² extension, or the older Open Book extension, can create a bookmark and add keyword property at the same time. An alternative is Keyword addition for Add/Change Bookmark (Fx3) | userstyles.org as a style used with the Stylish extension that can be customized.

Specifying a non-UTF-8 encoding in the query

By default, %s-replaced query terms are sent to the server in UTF-8 encoding. Some servers, however, use other encoding in their query string, especially in the non-Western environment to result in misinterpreted or garbled query. The mozcharset= parameter has been introduced to work around this problem in Bug 258223.

For example, Korean computer jargon dictionary uses EUC-KR encoding. Normal keyword search such as,

http://word.tta.or.kr/terms/terms.jsp?search=%s

produces incorrect result when supplied with non-ASCII query term 파일. By appending mozcharset=charset parameter, as in

http://word.tta.or.kr/terms/terms.jsp?search=%s&mozcharset=EUC-KR

users are directed to the correct result page.

Caveat: mozcharset=charset parameter should be appended at the end of the query string with the preceding &.

See also

External links