liveBook · Manning

Code suggestion

As explained in Learn AI-Assisted Python Programming, Second Edition

A code suggestion is a proposed source-code completion or generation presented to a programmer for possible acceptance.

A code suggestion is a proposed completion or generation that Copilot displays for possible acceptance. It behaves like sophisticated autocomplete: comments can describe a task, and Copilot may respond with code or more comments. section 2.6.1

Work with a suggestion in the editor:

  • Write a comment describing the desired code, then press Enter and pause. section 2.6.1
  • Look for light-gray italic text, pressing Enter again if necessary. section 2.6.1
  • Press Tab to accept the proposed code; accepted text changes to the standard font. section 2.6.1
  • Use Ctrl-Enter to open the GitHub Copilot Suggestions window when an inline suggestion does not appear. section 2.6.1

Prompting a simple output

Typing the comment `# output "Hello Copilot" to the screen` can produce `print("Hello Copilot")`. The exact suggestion may differ because Copilot is nondeterministic. section 2.6.1

Figure 2.4 VS Code interface with Copilot running
figure

Use the editor view to identify the prompt, gray unaccepted suggestion, and accepted code. section 2.6.1

How Learn AI-Assisted Python Programming, Second Edition covers it

How deep it goes
Explains prompting, visual states, acceptance, and troubleshooting, but does not descend into generation internals.
Examples
Demonstrates a comment-to-print completion and shows the VS Code Copilot interface.
What it assumes
Assumes a functioning Copilot and VS Code setup while teaching comments as prompts from the editor workflow.
What you can do after
Operate GitHub Copilot suggestions by prompting, triggering, accepting, and troubleshooting proposed code.
How it connects
Connects comments, autocomplete, code generation, and editor workflows.

Also explained in

Compare how 2 books explain code suggestion →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Learn AI-Assisted Python Programming, Second Edition. The section links point to the parts of the book it draws on.