2

Current behavior:

GitHub Copilot console.log() suggestion:

console.log('userId:', userId);

Expected suggestion with desired custom formatting:

console.log('userId: ', userId);

Is there a way to configure Copilot so its console.log() inline suggestions consistently include that space inside the string before the variable?

This question applies not only to console.log(), but also to custom formatting for inline code completion suggestions in general.

6
  • console.log already adds a space between each argument... You want 2 spaces when printing? Commented Sep 12 at 21:07
  • 1
    @MattSchlosser Yes. In a broader and general sense, any kind of additional custom formatting/pattern. Commented Sep 13 at 23:20
  • 2
    It's not possible at the moment, AFAIK. the autocompletion uses the gpt4.1 completion whose endpoint is https://proxy.individual.githubcopilot.com/v1/engines/gpt-41-copilot/completions it just does not read any instructions at all. Commented Sep 16 at 23:21
  • @kakaiikaka Praise the sun! Technology progresses too slowly. Commented Sep 17 at 14:40
  • I agree with above, it is not directly possible. However, there may be options to apply formatting using an extension, formatter, or settings. These vary by language being used. Is there a specific language you're using this with? Commented Sep 17 at 19:08

1 Answer 1

2
+50

I tried creating a .github/copilot-instructions.md (see custom instructions for GitHub Copilot), where I could have specified your rule for Code completions.

But... as mentioned in "Use custom instructions in VS Code":

Custom instructions are not taken into account for code completions as you type in the editor.

However, adding in my code a comment like seemed to guide the completion logic:

// Any console.log string before a variable should be ending with a space

I still had to insert a missing space in console.log('test:', test); to make it console.log('test: ', test);.

But by the second or third instance of console.log('job_id, the completion correctly suggested console.log('job_id: ', job_id);.

It does so consistently for the current file, but still has to be "educated" again on the next file.

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

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.