You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: learn-pr/github/github-copilot-across-environments/includes/2-code-completion-with-git-hub-copilot.md
+14-9Lines changed: 14 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,18 +2,19 @@ GitHub Copilot code completion features live directly within your IDE, where you
2
2
3
3
In this unit, we cover:
4
4
5
-
- GitHub Copilot supported languages
5
+
- GitHub Copilot supported languages
6
6
- Auto suggestions
7
7
- Multiple suggestions pane
8
8
- Support for different coding styles in suggestions
9
9
- How GitHub Copilot incorporates coding comments for suggestions
10
10
11
-
12
11
## GitHub Copilot supported languages
12
+
13
13
GitHub Copilot provides robust support for a wide range of programming languages and frameworks, with strong capabilities in:
14
14
15
15
- Python
16
16
- JavaScript
17
+
- Java
17
18
- TypeScript
18
19
- Ruby
19
20
- Go
@@ -22,21 +23,22 @@ GitHub Copilot provides robust support for a wide range of programming languages
22
23
23
24
While these languages receive exceptional support, GitHub Copilot can assist with many other languages and frameworks as well.
24
25
25
-
26
26
## Auto suggestions
27
+
27
28
Copilot offers code suggestions as you type: sometimes completing the current line, sometimes suggesting a whole new block of code. You can accept all, part, or ignore the suggestion. This ability to provide real-time, context-aware suggestions saves valuable development time by reducing the need to search for syntax, troubleshoot logic, or repeatedly write common patterns.
28
29
29
30
:::image type="content" source="../media/auto-completion-ghost-text.png" alt-text="Screenshot of auto completion ghost text.":::
30
31
31
-
32
32
## Multiple suggestions pane
33
+
33
34
When you're working on a code block and GitHub Copilot offers a suggestion, you see a grayed-out code snippet. To explore more options, hover over the suggestion to reveal the GitHub Copilot control panel.
34
35
35
36
:::image type="content" source="../media/multiple-suggestion-auto-completion-ghost-text.png" alt-text="Screenshot of multiple suggestion auto completion ghost text.":::
36
37
37
38
Click the forward or backward arrow buttons in the control panel to see the next or previous suggestions. You can also use keyboard shortcuts:
38
-
- macOS: Option (⌥) or Alt+] (next), Option (⌥) or Alt+[ (previous)
39
-
- Windows or Linux: Alt+] (next), Alt+[ (previous)
39
+
40
+
- macOS: Option (⌥) or Alt+] (next), Option (⌥) or Alt+[ (previous)
41
+
- Windows or Linux: Alt+] (next), Alt+[ (previous)
40
42
41
43
:::image type="content" source="../media/suggestions-pane.gif" alt-text="Screenrecord of suggestions pane.":::
42
44
@@ -48,28 +50,31 @@ While GitHub Copilot is superb at suggesting code for you, it also demonstrates
48
50
-**Comment Style**: It can mimic your comment style, whether you prefer inline comments, block comments, or doc strings.
49
51
-**Design Patterns**: When your project consistently uses certain design patterns, Copilot suggests code that aligns with these patterns.
50
52
51
-
52
53
## Using coding comments for suggestions
54
+
53
55
A key aspect of this capability is how it incorporates coding comments to enhance its suggestions. This section explores the various ways GitHub Copilot utilizes comments to improve its code completion and generation capabilities.
54
56
55
57
### Understanding comment context
58
+
56
59
When integrated into your existing codebase, GitHub Copilot uses various aspects of your code to provide more relevant suggestions, including code comments. Developers often use comments to clarify code intent and enhance collaboration, and Copilot, as your AI coding assistant, makes use of these comments in much the same way. By understanding the intent behind the comments, Copilot can provide more accurate and context-aware code suggestions through two key processes:
57
60
58
61
-**Natural Language Processing**: Copilot uses advanced natural language processing (NLP) techniques to interpret the meaning and intent behind comments in the code.
59
62
-**Contextual Analysis**: It analyzes comments in relation to the surrounding code, understanding their relevance and purpose within the broader context of the file or project.
60
63
61
-
62
64
## Types of comments utilized
65
+
63
66
Copilot can work with various types of comments to inform its suggestions:
67
+
64
68
-**Inline comments**: Short explanations next to specific lines of code.
65
69
-**Block comments**: Longer explanations that might describe a function or class.
66
70
-**Docstrings**: Formal documentation strings in languages like Python.
67
71
-**TODO comments**: Notes about future implementations or improvements.
68
72
-**API Documentation**: Comments that describe the usage and parameters of functions or methods.
69
73
70
-
71
74
## Comment-driven code generation
75
+
72
76
Copilot uses comments in several ways to generate and suggest code:
77
+
73
78
-**Function implementation**: When a function is described in comments, Copilot can suggest an entire implementation based on that description.
74
79
75
80
:::image type="content" source="../media/multiple-line-code-completion-ghost-text.png" alt-text="Screenshot of multiple line code completion ghost text.":::
0 commit comments