Completion Dictionary 4.1

Overview
Features
System Requirements
Installation
Customizing the completion shortcut
Configuration
Usage
Web Links

Overview

Completion Dictionary is a free Xcode plugin that enhances Xcode’s built-in code completion mechanism. You simply type a few letters - either the abbreviation of a macro or the initials of a symbol name - and press the completion shortcut. Completion Dictionary will do the rest.

Macro Expansion

A set of user defined macros is searched for an entry matching the abbreviation you’ve typed in. The macros may also contain a number of placeholders. The text range of these placeholders will be preselected, ready to be replaced with your further input.

Code Completion

Completion Dictionary integrates the built-in code completion capabilities of Xcode. If there’s no macro found for a given abbreviation, Xcode’s code completion will be performed instead of macro expansion.

Features

What’s new in version 4.1

What’s new in version 4.0

System Requirements

Installation

For Xcode 3, copy ODCompletionDictionary.xcplugin to one of these locations:

/Library/Application Support/Developer/Shared/Xcode/Plug-ins/
~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/

For Xcode 2, copy ODCompletionDictionary.pbplugin to one of these locations:

/Library/Application Support/Apple/Developer Tools/Plug-ins/
~/Library/Application Support/Apple/Developer Tools/Plug-ins/

Finally, quit and restart Xcode. After successful installation Completion Dictionary logs its version number to the Console whenever the plugin gets loaded into Xcode.

Upgrading from versions prior to 4.0

Completion Dictionary 4.0 stores its configuration data in a new location. You therefore have to move and rename an existing configuration file from ~/Library/KeyBindings/CompletionKeyBinding.dict to ~/Library/Application Support/Completion Dictionary/Configuration.plist.

Further, the completion method selector has changed from completeUsingDictionary: to completionDictionaryExpandMacro:, so you have to update your key bindings as described in the following section.

Customizing the completion shortcut

By default the Edit > Completion Dictionary > Expand Macro command can be invoked with Control-Escape. You may customize this shortcut in Xcode’s Key Bindings preferences.

Unfortunately, Xcode doesn’t let you bind the Escape key (without any modifiers) to a menu command, which would be a very convenient shortcut though. However, it is possible to establish this binding by editing the appropriate key binding file manually.

When using the default Key Binding Set

If you haven’t yet created a custom “Key Binding Set” in Xcode’s Key Bindings preferences, you can establish the key binding in

~/Library/KeyBindings/PBKeyBinding.dict

This file must contain at least the following lines:

{
    "\U001B" = "completionDictionaryExpandMacro:";
}

When using a custom Key Binding Set

If you are using a custom key binding set, Xcode ignores the settings in PBKeyBinding.dict. Therefore you must edit your custom key bindings file instead, which can be found at

~/Library/Application Support/Xcode/Key Bindings/*.pbxkeys

Open this file in Property List Editor, select Edit > Show Strings as Unicode and add a key binding to the “text” dictionary where the key is \U001B and the selector is completionDictionaryExpandMacro:.

Note: If you are upgrading from a Completion Dictionary version prior to 4.0 you have to update your existing Completion Dictionary key binding and change the selector from completeUsingDictionary: to completionDictionaryExpandMacro: either in PBKeyBinding.dict or in your custom *.pbxkeys file.

Configuration

Choose Edit > Completion Dictionary > Edit Macros or type Command-Option-Comma to open the macro editor. You will see a set of pre-installed example macros, ready to be used immediately. You can add your own macros by entering several abbreviation-macro pairs, e.g:

Abbreviation Macro
ls NSLocalizedString(@"<#string#>", @"<#comment#>")
oi objectAtIndex:<#index#>
span <span class="<#?class#>"><#text#></span>
( (<#%clipboard#>)

Placeholders

A macro may contain one or more placeholders for variable names, arguments and other program-specific information. A placeholder is delimited by <# and #> and can be inserted conveniently by choosing an item from the Insert Placeholder pull down menu.

Restoring the default configuration

Completion Dictionary includes a comprehensive set of default macros, illustrating lots of the plugin’s capabilities. They provide a good starting point for your own macro definitions. If you wish to restore the default configuration at a later point, you just have to remove (or rename) your custom configuration file at

~/Library/Application Support/Completion Dictionary/Configuration.plist

and restart Xcode.

The default configuration includes macros for C, Objective-C and HTML. Here are just a few noteworthy macros:

Usage

Once you’ve configured the dictionary you can use it as follows: Type the abbreviation and press the completion shortcut (Control-Escape by default). If the abbreviation is found in the dictionary, the corresponding macro is inserted, otherwise Xcode’s built-in code completion is invoked. If the completion doesn’t deliver the desired results, you can undo this operation with Command-Z.

If the macro contains any placeholder the first placeholder will be selected, so you can replace it with your own code right away. If there’s more than one placeholder you can cycle through the placeholders by either choosing Edit > Select Next Placeholder or typing Control-/.

If the macro contains any query placeholder, a panel will appear, allowing you to fill out the requested fields. Note that you can navigate through the fields using the up/down arrow keys. Once you’ve completed your input you can confirm with Return or dismiss this panel by pressing Escape.

Web Links