Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

Note: As of version 9, this functionality is available and works out of the box.


I've a few questions about Command Completion in Mathematica. I recently discovered this feature, and it's really convenient. However, it gets tiring to hit Ctrl-K all the time.

Is there a way to turn Command Complete on after every keystroke, like autocompletion is for many programming IDE's?

Or, failing that, to map it to another key like Tab, which I find much more convenient to hit? I've looked up some internet sources on changing Keyboard shortcuts for Mathematica, but they all seem pretty complicated.

share|improve this question
    
I know this doesn't answer your question, but, have you tried Ctr-Shift-K? Then you can Tab between fields in a complete expression. –  Eli Lansey Apr 20 '12 at 21:28
1  
At least on Windows, you can use <F2> as an alternative to <Ctrl>-<K>. I can't test it right now but I'd be surprised if that didn't also work on other platforms. –  Oleksandr R. Apr 20 '12 at 21:28
    
@OleksandrR. F2 doesn’t work on Mac OS X –  F'x Apr 20 '12 at 21:33
    
@OleksandrR.You're right, F2 does work. My F2 key is extremely small, however, and it's always annoying to hit F1 when you meant to hit F2. I'm using Fedora 16 by the way. –  xiongtx Apr 20 '12 at 21:33
2  
Version 9 has a completely reworked autocompletion system –  Sjoerd C. de Vries Nov 28 '12 at 22:00
add comment

2 Answers

Changing shortcuts isn't that complicated. All you have to do is change one line in the file KeyEventTranslations.tr in a location in your file system specified by this command:

FileNameJoin[{$InstallationDirectory, "SystemFiles", "FrontEnd", 
  "TextResources", $OperatingSystem}]

Locate the following line in a text editor and change the key into the one you want:

Item[KeyEvent["F2"], FrontEnd`CompleteSelection[True]]

I wouldn't use tab, as that already has a built-in meaning.

More information can be found here.

share|improve this answer
4  
I do not recommend modifying system files. Instead make a user copy and modify that. –  Mr.Wizard Apr 21 '12 at 6:24
add comment

You can also use hotstrings as a way of autocompletion. By using such replacements, words are immediately replaced by another word on typing a space after the hotstring:

CreateDocument[{}, InputAutoReplacements -> {"sync" -> SynchronousInitialization}]

You can set such replacements globally under Option Inspector (CtrlShiftO). Of course no one would do it far all built-in commands, but it is useful for the more frequent ones.

share|improve this answer
add comment

Your Answer

 
discard

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.