Copilot 引入两项强大的新功能:斜线命令(/)和上下文变量(#)

可以在这里订阅 Github 官方 Copilot 更新 RSS
https://github.blog/changelog/label/copilot/feed/

以下是报道全文,直接 copy 过来了 :rofl:


Slash Commands 斜线命令

Slash commands are special commands that you can use in chat to receive targeted assistance, including explanations, documentation, test creation, and various other forms of support related to your code. For example, you can use:
斜杠命令是特殊命令,您可以在聊天中使用它们来获得有针对性的帮助,包括解释、文档、测试创建以及与代码相关的各种其他形式的支持。例如,您可以使用:

  • /doc to add a documentation comment
    /doc 添加文档注释
  • /explain to explain the code
    /explain 解释代码
  • /fix to propose a fix for the problems in the selected code
    /fix 对所选代码中的问题提出修复建议
  • /generate to generate code to answer your question
    /generate 生成代码来回答您的问题
  • /help to get help with Copilot Chat
    /help 获取有关副驾驶聊天的帮助
  • /optimize to analyze and improve the running time of the selected code
    /optimize 分析并改进所选代码的运行时间
  • /tests to create unit tests for the selected code
    /tests 为所选代码创建单元测试

Context Variables 上下文变量

The context variables feature enables you to add files from your solution into your questions using the # symbol. By referencing a file in this way, you allow Copilot to access the content of the file and provide more targeted answers about it. For example, you can ask “How does the #file:’Main.cs’ file work?” or “What is the purpose of the #file:’Calculator.cs’ file?” and get relevant answers from Copilot Chat. You can add multiple files to one question.
上下文变量功能使您能够使用 # 符号将解决方案中的文件添加到问题中。通过以这种方式引用文件,您可以允许 Copilot 访问该文件的内容并提供更有针对性的答案。例如,您可以询问“#file:‘Main.cs’ 文件如何工作?”或“#file:‘Calculator.cs’ 文件的用途是什么?”并从副驾驶聊天中获取相关答案。您可以将多个文件添加到一个问题。

Besides these main features, you can also explore our other exciting new preview features
除了这些主要功能之外,您还可以探索我们其他令人兴奋的新预览功能