Tips for using Github Copilot in Vim

Based on a few weeks of using vim-copilot, I recommend the following:

  1. Enable Copilot for the gitcommit, markdown and yaml filetypes:

    let g:copilot_filetypes = {
        \ 'gitcommit': v:true,
        \ 'markdown': v:true,
        \ 'yaml': v:true
        \ }

    By default, these and few others are disabled but I’ve found them to be useful. It’s often amusing to see Copilot’s attempts to complete your commit messages.

  2. Disable Copilot for large files as it can be slow and impair the editing experience:

     autocmd BufReadPre *
         \ let f=getfsize(expand("<afile>"))
         \ | if f > 100000 || f == -2
         \ | let b:copilot_enabled = v:false
         \ | endif

    This autocommand disables Copilot for files larger than 100KB. See my related TIL post for more details on this.


Something wrong? Suggest an improvement or add a comment (see article history)
Tagged with: Vim, Github Copilot
Filed in: tips

Previous: Creating pull requests with GPT3 and random artwork

Copyright © 2005-2023 David Winterbottom
Content licensed under CC BY-NC-SA 4.0.