Interact with Github Copilot

Inline Chat

  1. Seleccionar el código para la query
  2. alt + ç
  3. hacer la pregunta

Algunos comandos útiles para inline chat son

  • /doc - añade comentarios al código
  • /explain - conseguir explicaciones sobre código
  • /fix - propose fixes for problems in the selected code
  • /generate - generar código para responder a una pregunta específica
  • /optimize - analizar y optimizar código seleccionado
  • /tests - generates unit tests for the selected code
  • /comment - converts comments into code snippets
  • /suggest - offer code suggestions based on the current context

Comments to code

You write a comment and the function name/input and when you hit Enter copilot completes with code

# function to iterate all prompts and print them
def iterate_and_print(prompts):

then copilot completes it to this

# function to iterate all prompts and print them
def iterate_and_print(prompts):
    for idx, prompt in enumerate(prompts):
        var_name = chr(ord('A') + idx)
        print(f"Prompt {var_name}:\n{prompt}\n")

Copilot chat

Comandos compatibles con contexto #

# guia a copilot a archivos especificos

genera una funcion para quitar un elemento de mi cesta en #BasketService.cs

De todos modos copilot mete en contexto todas las pestañas que tienes abiertas.

Comandos de barra diagonal /

para ver todos los comandos escribe /

  • /explain #BasketService.cs - obtener una explicacion del archivo
  • /fix #OrderService.cs - sugerir correcciones para problemas
  • /optimize - optimiza código
  • /test #UserService.cs - generar pruebas unitarias

Sugerencias en texto gris

alt + / - iniciar chat en linea para formular preguntas sobre codigo seleccionado alt + , - desencadenar finalizacion con copilot recorrer las finalizaciones

  • alt + . - siguiente
  • alt + , anterior

Uso de agentes

@workspace

Permite a Copilot comprender un contexto más amplio sobre los projectos y configuraciones

  • útil para hacer preguntas a Copilot sobre todo el proyecto
  • útil para generar código que encaje en todo el proyecto, usando referencias del mismo
    @workspace where is the function for GetMetadata?
    

smart action /new

Se puede usar la siguiente smart action para generar

@terminal

Agente útil para preguntas sobre CLI

Through secondary menu

  1. Select the code you want to interact with
  2. right click
  3. acciones de copilot > whichever one you want

    Inline suggestions

    As you type copilot offers real-time completions

    • To accept a suggestion - Tab key
    • To reject a suggestion - keep typing or Esc key

Command palette

Quick access to various functions (no me funciona)

  1. Press Ctrl+Shift+P
  2. Enter Copilot to see commands
  3. Select an action

    Extensiones de Github Copilot

    Buscar o mirar extrensiones compatibles en Github Marketplace