Command Completion



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.

Tianxiang Xiong

Posted 2012-04-20T21:18:32.843

Reputation: 893

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 – 2012-04-20T21:28:24.890

1At 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. – 2012-04-20T21:28:40.817

@OleksandrR. F2 doesn’t work on Mac OS X – F'x – 2012-04-20T21:33:15.877

@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. – Tianxiang Xiong – 2012-04-20T21:33:30.720

Uf on Windows Autohotkey will allow to map it to any key. – William – 2015-02-01T23:58:39.493

2Version 9 has a completely reworked autocompletion system – Sjoerd C. de Vries – 2012-11-28T22:00:33.733



Changing shortcuts isn't that complicated. All you have to do is change one line in the file 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.

Sjoerd C. de Vries

Posted 2012-04-20T21:18:32.843

Reputation: 63 549


I do not recommend modifying system files. Instead make a user copy and modify that.

– Mr.Wizard – 2012-04-21T06:24:51.553


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.

István Zachar

Posted 2012-04-20T21:18:32.843

Reputation: 44 135