6

Is there any easy way of directly jumping to the definition of a Variable like it is implemented in some good IDEs? Currently I have to search manually (ctrl+f) through the whole workbook to find it somewhere.

Ferio
  • 161
  • 2
  • Thank you that helps. I hoped for a Right-Mouse-Button-Solution. So I have to use a new cell and evaluate it, but that will work. – Ferio Mar 08 '13 at 09:15
  • 3
    @Ferio: I don't think it is possible to solve this in general. As in Mathematica there can be many definitions for one symbol and these could in principle be distributed over different locations and files there isn't something like single point of definition. Maybe that's the reason why no such functionality is available. When you use a personal convention to mark where a certain symbols definition appears it should be simple enough to write something. If you are interested in such an approach I'd suggest to indicate that in your question and I'm sure you'll get some help... – Albert Retey Mar 08 '13 at 09:32
  • 1
    @Nasser: I think the problem with source line numbers is that the structure of a notebook-expression isn't line oriented: there isn't anything like a defined line number within a notebook. This has been discussed several times in questions about Mathematica files and version control systems, which you can search if interested in more details. When used as a package file editor, it would in principle be possible to define line numbers and the package-file editor for Wolfram Workbench actually has them... – Albert Retey Mar 08 '13 at 09:38
  • 1
    @Nasser: what is somewhat ridiculous is the fact that Get reports line numbers for syntax errors in package files but you need external editors to actually find those lines. So yes, there seems to be room for improvement... – Albert Retey Mar 08 '13 at 09:40
  • 2
    @Ferio Have a look at wolfram workbench. I gave up on the front end for writing packages and I don't regret it at all. – Ajasja Mar 08 '13 at 13:31
  • 2
    @Ajasja is right. The workbench is more convenient for writing things. Would have been nice if we had the workbench features in the frontend... – acl Mar 08 '13 at 13:56
  • @Nasser: when you copy Mathematica source code from the notebook, it basically does a "convert to input form" in the background and the result is plain text with fixed line breaks which of course is a form for which line numbers make sense. What really is contained in the notebook (except for specially styled cells) is more complicated, and for that there isn't a meaningful line number. I'm not saying that all that is perfect and couldn't be improved, but there is a reason for it to be as it is. If in doubt, open a .nb-file in a text editor and make a guess about line numbers... – Albert Retey Mar 08 '13 at 18:05
  • If you need to edit the definition in the front end, I think you're stuck with doing a search. But if you just want to see the definition of object func, use ?func or ??func. – murray Mar 08 '13 at 20:24

1 Answers1

5

If you use package files, ie, files with extension .m which contain mathematica code in plain text; create one from File->New->Package:

enter image description here

there is a button which lets you jump to the definition of symbols:

enter image description here

Clicking it shows a list of functions:

enter image description here

(although it gets confused sometimes, as you can see in this screenshot); clicking on a symbol name usually takes you to the assignment (if eg you have them all in one cell, this doesn't work...).

Now, the m-editor is not ideal, but better than searching. Note that by default it does not keep the indentation when you press return; this may be changed as described here. Also, block-indenting in this editor is impossible...

acl
  • 19,834
  • 3
  • 66
  • 91