4
$\begingroup$

I'm used to do

??symbol

when I want the reference for a given symbol, then I click on the >> arrows to open the help window.

Would it be possible to redefine the meaning of ?? in order to open the reference window directly ?

$\endgroup$
4
  • 1
    $\begingroup$ You can simply write down the symbol and then press F1. $\endgroup$
    – xzczd
    Commented Feb 5, 2014 at 10:10
  • 2
    $\begingroup$ Are you aware that you can place the cursor in the Symbol name (or select it with a double-click) and press F1 to bring up the Help for that item? $\endgroup$
    – Mr.Wizard
    Commented Feb 5, 2014 at 10:10
  • $\begingroup$ I didn't know that ... $\endgroup$
    – Cedric H.
    Commented Feb 5, 2014 at 11:16
  • $\begingroup$ Related/Possible duplicate: Open and search Documentation-Center $\endgroup$
    – rm -rf
    Commented Feb 5, 2014 at 16:48

2 Answers 2

9
$\begingroup$

The simplest (and canonical) method is to place the keyboard cursor in the Symbol name, or select it with a double-click, and press F1 if you use Windows/Linux or Command-Shift-F if you use OS X. This will bring up the Help for that item. This also works with compound operators, e.g. /;.

Nevertheless I like a challenge, therefore:

$PreRead =
  # /. RowBox[{"??", name_String}] :>
    FrontEndTokenExecute["OpenHelpLink", name] &;

Now this brings up the Help page for Fold directly:

?? Fold

While this will search the documentation for the term "Fold":

?? "Fold"

I chose $PreRead for this purpose so that it will not interfere with internal calls to Information.
You can also get the original behavior by writing out Information, e.g.:

? Plus

x+y+z represents a sum of terms.  >>

Information[Plus]  (* equivalent to ??Plus *)

x+y+z represents a sum of terms.  >>

Attributes[Plus]={Flat,Listable,NumericFunction,OneIdentity,Orderless,Protected}

Default[Plus]:=0
$\endgroup$
3
  • 2
    $\begingroup$ @Kuba Yes, the same in v7, which is why I stated "place the keyboard cursor in the Symbol name" but you need to select some operators for F1 to work; for example, try placing the cursor between the two ^ characters in 2^^10010 -- it does not work. However, selecting ^^ and pressing F1 directs you to the documentation for BaseForm. $\endgroup$
    – Mr.Wizard
    Commented Feb 5, 2014 at 10:32
  • $\begingroup$ Good point :).. $\endgroup$
    – Kuba
    Commented Feb 5, 2014 at 10:35
  • $\begingroup$ Note that on OS X, F1 also works. $\endgroup$ Commented Feb 5, 2014 at 18:40
3
$\begingroup$

The typical way to search the documentation is the keyboard shortcut Mr Wizard mentioned. In general, you can find the shortcut key for a command by looking in the menu ...

enter image description here

If you are looking for a built-in way to open a documentation pages using a built-in command, then you are looking for Documentation`HelpLookup.

Documentation`HelpLookup["euler"]

will open the documentation centre and do a search for "euler". It returns a reference to the notebook window containing the search result. The behaviour equivalent to typing the search term into the documentation search box.

$\endgroup$
9
  • 1
    $\begingroup$ This method appears to have a massive overhead compared to "OpenHelpLink". Documentation`HelpLookup["Fold"] // Trace // LeafCount yields 104848 while FrontEndTokenExecute["OpenHelpLink", "Fold"] // Trace // LeafCount yields 21. What is HelpLookup doing and what is its benefit over "OpenHelpLink"? $\endgroup$
    – Mr.Wizard
    Commented Feb 5, 2014 at 16:36
  • $\begingroup$ @Mr.Wizard As Szabolcs said, HelpLookup returns a notebook object, which can be very useful whereas "OpenHelpLink" returns Null, which makes it useful only for this particular evaluation and cannot be used in other programs/applications, etc. More importantly, does the leaf count matter for OP's question? :) $\endgroup$
    – rm -rf
    Commented Feb 5, 2014 at 16:50
  • $\begingroup$ @rm-rf In version 7 HelpLookup also returns Null. It may not matter, but it does make me wonder about the overhead, and if given the choice between two methods that are apparently otherwise equivalent (in v7) I'll pick the one that seems to have less overhead. $\endgroup$
    – Mr.Wizard
    Commented Feb 5, 2014 at 17:54
  • 1
    $\begingroup$ @Mr.Wizard It's an interactive operation. You are going to look at the result and read it. Does it really matter if it takes 0.1 seconds or 0.01 seconds, or does it really influence your choice? ;-) Also, what takes longer: opening the window and displaying the contents or running the function in the kernel? $\endgroup$
    – Szabolcs
    Commented Feb 5, 2014 at 18:10
  • 1
    $\begingroup$ @Mr.Wizard I would have used HelpLookup for the simple reason that I've seen it before and I remembered it, so it's less searching for me. I think you'd use OpenHelpLink for the same reason. I think that ultimately both will end up running the same code, and that OpenHelpLink will end up doing kernel evaluations as well. This is a guess that might be wrong. One might test it by using LinkSnooper to monitor the kernel-frontend communication during help lookup, but I don't think I'm going to spend the time to do it. $\endgroup$
    – Szabolcs
    Commented Feb 5, 2014 at 18:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.