Copilot 是否可以帮助我学习编码?
是! Copilot 可在整个编码旅程中适应你不断变化的需求。 当你成为经验丰富的开发人员时,你将使用 Copilot 作为编码助手。 当你学习编码时,它能作为“支持伙伴”带来更多益处****。
在本指南中,你将学习如何设置 Copilot,以使其充当导师来帮助你深入理解编程概念,而不是依赖它为你编写代码****。 为优化学习,请对你使用的每个存储库执行以下步骤。
先决条件
本指南假定你使用 VS Code 中的 Copilot。 要完成设置,请参阅 Visual Studio Code 文档中的在 VS Code 中设置 Copilot。
第 1 步:禁用代码补全
首先,禁用代码补全。 这将使你有机会通过自己编写更多代码来深入理解编码概念。
-
在 VS Code 中,打开你的项目。
-
在名为
.vscode
的根目录中创建文件夹。 -
在
.vscode
中,创建名为settings.json
的文件。 -
将以下文本添加到该文件:
JSON { "github.copilot.enable": { "*": false } }
{ "github.copilot.enable": { "*": false } }
-
保存文件。 VS Code 中现已针对此项目禁用 Copilot 代码补全。
第 2 步:添加学习说明
现在为 Copilot Chat 提供说明以使它充当导师来为你的学习提供支持。
-
在项目的根文件夹中,创建名为
copilot-instructions.md
的文件。 -
添加以下文本,或针对个人学习目标对其进行自定义:
Markdown I am learning to code. You are to act as a tutor; assume I am a beginning coder. Teach me coding concepts and best practices, but do not provide solutions. Explain code conceptually and help me understand what is happening in the code without giving answers. Do not provide code snippets, even if I ask you for implementation advice in my prompts. Teach me all the basic coding concepts in your answers. And help me understand the overarching approach that you are suggesting. Whenever possible, share links to relevant external documentation and sources of truth. At the end of every response, add "Always check the correctness of AI-generated responses."
I am learning to code. You are to act as a tutor; assume I am a beginning coder. Teach me coding concepts and best practices, but do not provide solutions. Explain code conceptually and help me understand what is happening in the code without giving answers. Do not provide code snippets, even if I ask you for implementation advice in my prompts. Teach me all the basic coding concepts in your answers. And help me understand the overarching approach that you are suggesting. Whenever possible, share links to relevant external documentation and sources of truth. At the end of every response, add "Always check the correctness of AI-generated responses."
-
保存文件。 当你在 Copilot Chat 中提问时,Copilot 将使用这些说明。
第 3 步:使用 Copilot Chat 学习
现在即可在 Copilot 的帮助下开始培养真正的编码技能。
在处理此项目的整个过程中,请与 Copilot Chat 进行长时间的对话****。 将它当作你的个人导师,在遇到问题时提问并使用它来应对挑战或澄清概念****。
Tip
可以使用键盘快捷方式打开 Copilot Chat:Ctrl+Alt+I (Windows/Linux) 或 Command+Shift+I (Mac)。
Copilot Chat 对调试代码尤其有帮助。 有关分步指导,请参阅“学习使用 GitHub Copilot 进行调试”。