Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible in v9 to autocomplete the short symbol names when one is operating in a context other than Global`? I.e. after evaluating the following:


Starting to write MyCon... will autocomplete and give MyContext`xyz as an option. That's not what I want. I want to write x and get autocomplete to suggest xyz. I tried adding MyContext` to $ContextPath but that doesn't do anything. Of course if I were to exit MyContext` and return to Global` I don't expect it to autocomplete the short name anymore. Also, I noticed that the symbol coloring is off too, so that xyz appears to have no value assigned (blue colored) even though it obviously does have a value.

share|improve this question
In M9 all defined variables are autocompleted - is it not what you need? – Vitaliy Kaurov Apr 3 '13 at 18:12
Yes, it autocompletes for me too. Re: your second question, you can do SetOptions[$FrontEnd, AutoStyleOptions -> {"SymbolContextStyles" -> {"MyContext`" -> Green}}] – R. M. Apr 3 '13 at 18:15
That's strange. It doesn't autocomplete for me, and I tried it both on Mac and PC, and using 9.0.1... I do exactly what I said above, and unless I type MyCon... nothing happens. If I just starting typing x it just sits there. – Mohammed AlQuraishi Apr 3 '13 at 18:23
Hmm.. I think I can reproduce it if I do Begin[...] and work in it without calling End[]. The problem is that the FrontEnd has not yet recognized the new context (which it does when you call End[]) and my guess is that when you call it with the full context, it is the kernel that is providing this information. If you instead do Begin[...];AppendTo[$ContextPath,...];End[]; Begin[...], it works i.e., create your context and add it to the path, close it so that the FE recognizes it and then switch to it again. Enter those in separate lines, not as one. – R. M. Apr 3 '13 at 18:29
Does it auto-complete if you just do xyz=5; ? – Vitaliy Kaurov Apr 3 '13 at 18:34

Paraphrasing the insights of rm -rf:

  • To make highlighting and autocompletion work in new contexts you have to run: 1) Begin[...]; 2) AppendTo[$ContextPath,...] and 3) End[]. Then you have to open your context again: Begin[...];
  • Be sure to put each of (1), (2) and (3) in the previous bullet point in separate cells. They have to be evaluated separately or it won't work.
share|improve this answer
Thanks for the answer, but could you please provide a working example, because my auto-completion still does not work, when I repeat what you say. – Szczypawka Jul 29 '14 at 13:28

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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