17

When using GitHub Copilot with VS Code, by default, it uses Tab to accept CoPilot's suggestion.

But sometimes I want to genuinely make a tab at a point in the code where CoPilot has other ideas.

How can I make a tab in that position without triggering Copilot?

0

3 Answers 3

15

I assume you know you can hit Esc to get rid of the current suggestion and then hit Tab? I realize this may be common sense, but just in case, I wanted to point it out!

But, that does ruin your flow.

If you want to actually change the key, you can follow the other folks in here that guide you to do that!

Sign up to request clarification or add additional context in comments.

3 Comments

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
I'm not sure about now - they may fixed some issues, but then... no, you couldn't. You press tab and get the suggestion, undo it, press esp, press tab and get the suggestion anyway. Sometimes you need do this a few times to make it work
Some users use tab to indent code. It is not practical to check every tab press if there is a suggestion and press esc to dismiss it.
8

Today there isn't a solution to this problem, but a possible workaround is to change the copilot shortcut that accepts the suggestion.

On VS Code: File>preferences>Keyboard shortcuts

and search for 'editor.action.inlineSuggest.commit', the command that accepts the Copilot suggestion.

I used the shortcut Alt+a to avoid conflicts with other commands.

Comments

4

With an inspiration from @SvMax I decided to just make a shortcut for tab. So, I have two ways to print tab - tab or alt+tab

To do so:

  1. CTRL+p -> >shortcuts json
  2. add the following config

enter image description here

{
  "key": "alt+tab",
  "command": "editor.action.insertSnippet",
  "args": {
     "snippet": "\t"
   }
},

enter image description here

That's it. Now if you see Copilot is trying to mess up your tab use alt+tab but if not you can use both alt+tab or tab.

But yes, it's so confusing that we should messing up with shortcuts in such a simple case. Hope they will fix it soon because now... I mean... Why anyone could think this suggestion can be useful? :)

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.