16
$\begingroup$

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.

$\endgroup$
6
  • $\begingroup$ 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. $\endgroup$
    – Eli Lansey
    Commented Apr 20, 2012 at 21:28
  • 1
    $\begingroup$ 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. $\endgroup$ Commented Apr 20, 2012 at 21:28
  • $\begingroup$ @OleksandrR. F2 doesn’t work on Mac OS X $\endgroup$
    – F'x
    Commented Apr 20, 2012 at 21:33
  • $\begingroup$ @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. $\endgroup$ Commented Apr 20, 2012 at 21:33
  • 2
    $\begingroup$ Version 9 has a completely reworked autocompletion system $\endgroup$ Commented Nov 28, 2012 at 22:00

2 Answers 2

14
$\begingroup$

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.

$\endgroup$
1
8
$\begingroup$

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.

$\endgroup$

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