<type>documentation</type>
<domain>ai</domain>
<id>suggest</id>
<title>AI Suggested Code Completion</title>
<date>$Date: 2006-05-24 22:53:07 -0400 (Wed, 24 May 2006) $</date>
<version>$Revision: 13098 $</version>
<product>pro+</product>

You can ask Wing Pro's AI integration to suggest code appropriate for your current
insertion point in the editor at any time by pressing ``Ctrl-?`` or ``Ctrl-Tab``. This
enters AI suggestion mode and sends a request off to the AI provider.

The request to the AI provider may take quite a while to complete, depending on the
complexity of the problem, but generally produces code that would take far longer to write
manually. Wing shows the status of the request in the status area in the bottom left of its
window.

Once a result is available, it is placed into the editor in provisional form and the
editor enters into AI suggestion mode. If you don't like the suggestion, you can press
``Ctrl-?`` again (or ``Tab`` while still in AI suggestion mode) to request another
suggestion. This can be done repeatedly, and you can traverse suggestions that you have
requested with ``Shift-Tab`` to move backwards and ``Tab`` to move forwards. Then press
``Enter`` to accept the current suggestion or ``Esc`` (or ``Ctrl-G`` or ``Esc Esc`` in
Emacs mode) to cancel and exit AI suggestion mode.

A single ``Undo`` will undo any changes inserted into the editor if you decide you did not
want the suggestion after you have already accepted it.

Note that moving the caret in the editor while waiting for an AI suggestion will
automatically cancel the pending request and exit AI suggestion mode.

**Context**

By default Wing sends only part or all of the current file with your AI suggestion request. If the code you
want the AI to write needs to know about other code in your project, you can ask Wing to include
that by setting up and selecting an AI context from the ``AI Suggestion Context`` item in the ``AI`` menu
or the AI Suggestion Context icon |suggest| in the top right of the editor. See `AI Request Context
<ref:ai/context>`__ for details.

.. |suggest| image:: icon:wingide-ai-context
  :class: inline-image

**Quality of Results**

The AI suggestion capability is useful primarily for filling in implementations where the amount of
code expected is relatively small and the requirements for it are obvious from the surrounding
existing code. When this is not the case, it is much better to use the ``AI Coder`` tool to describe
exactly what you want in more detail.

**Key Binding**

If you prefer a different key binding for this feature, you can bind the command
``ai-suggest-next`` to any key sequence with the `User Interface > Keyboard > Custom Key
Bindings <script:show_preferences_gui#prefname="gui.keymap-override">`__ preference.

