Skip to main content

Obtención de sugerencias de código en el IDE con GitHub Copilot

Use GitHub Copilot para obtener sugerencias de código en el editor.

Note

GitHub Copilot in Eclipse is in public preview and subject to change.

About GitHub Copilot and Eclipse

This guide demonstrates how to get coding suggestions from GitHub Copilot in Eclipse. To see instructions for other popular coding environments, use the tool switcher at the top of the page.

Prerequisites

To use GitHub Copilot in Eclipse, you must install the GitHub Copilot extension. See Installing the GitHub Copilot extension in your environment.

Getting code suggestions

GitHub Copilot offers coding suggestions as you type. For example, type this function header in a Java file:

Java
public int getDiff(int a, int b)

GitHub Copilot will automatically suggest the rest of the function. To accept the suggestion, press Tab. To discard the suggestion, press Esc.

You can also describe something you want to do using natural language within a comment, and Copilot will suggest the code to accomplish your goal. For example, type this comment in a Java file:

Java
/*
 * Return the difference between two different integers.
 */

GitHub Copilot will automatically suggest code.

Tip

If you receive limited or no suggestions from Copilot, you may have duplication detection enabled. For more information about duplication detection, see Managing Copilot policies as an individual subscriber.

Manually triggering code completion

You can also use keyboard shortcuts to trigger code completion.

OSTrigger code completion
macOSOption+Command+/
Windows or LinuxCtrl+Alt+/

Accepting partial suggestions

If you don't want to accept an entire suggestion from Copilot, you can accept the next word of a suggestion.

OSAccept next word
macOSCommand+
Windows or LinuxCtrl+

Next steps