Copilot 能帮助我学习编程吗?
是的!Copilot 可以在整个编程旅程中适应你的不断变化的需求。作为经验丰富的开发者时,你会将 Copilot 用作编码助手;而在学习编程时,它更适合作为 支持性的伙伴。
在本指南中,你将学习如何设置 Copilot 充当 导师,帮助你深入理解编程概念,而不是依赖它为你编写代码。为了优化学习效果,请在你使用的每个仓库中遵循以下步骤!
先决条件
本指南假设你将在 VS Code 中使用 Copilot。要进行设置,请参阅 Visual Studio Code 文档中的 在 VS Code 中设置 Copilot。
步骤 1:禁用 Copilot 行内建议
首先,让我们禁用行内建议。这将为你提供机会,通过自己编写更多代码来加深对编程概念的理解。
-
在 VS Code 中,打开你的项目。
-
在根目录下创建一个名为
.vscode的文件夹。 -
在
.vscode中,创建一个名为settings.json的文件。 -
将以下内容添加到文件中
JSON { "github.copilot.enable": { "*": false } }{ "github.copilot.enable": { "*": false } } -
保存文件。现在此项目在 VS Code 中的 Copilot 行内建议已被禁用。
步骤 2:添加学习指令
现在,让我们向 Copilot Chat 提供指令,使其充当支持你学习的导师。
-
在根目录下创建一个名为
.github的文件夹。 -
在
.github中,创建一个名为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 进行长期对话。将其视为你的 个人导师,在问题出现时提问,并利用它来解决挑战或澄清概念。
在 VS Code 中打开 Copilot ChatCopilot Chat 在调试代码时尤其有帮助。有关分步指导,请参阅 使用 GitHub Copilot 学习调试。