yoKurt
yoKurt

Reputation: 537

How to use "Next/Previous" suggestion shortcuts for Github Copilot on a Mac?

I am trying to use GitHub Copilot on my Mac with Pycharm. Tab works great but I can't cycle through the previous and next code suggestion. Documentation says I should use:

Option+]
 
Option+[

but if I do, I only get brackets in my code. I should just press Option + 5 or Option + 6 right?

Upvotes: 48

Views: 54336

Answers (7)

somedotnetguy
somedotnetguy

Reputation: 938

For Visual Studio, Windows (11) English Version German Keyboard the default seems to be:

ALT+.
ALT+,

The setting can be found Tools -> Options -> (in dialog) Environment -> Keyboard ->

Edit.NextSuggestion
Edit.PreviousSuggestion

Or simply type in the search box: "suggest".

Note: Sadly first trying to type "copilot" did not work, since this feature does not have that in the name (others have).

Note: I know this question is for Mac, but I found this first, even though I was looking for a windows solution, so here it is.

VS Options

Upvotes: 0

Stefano Messina
Stefano Messina

Reputation: 2074

Try with Alt+] and Alt+[ on GNU/Linux. For other Keyboard shortcuts, for all other Operating Systems and IDEs/Editors, refer to the link: https://docs.github.com/en/copilot/configuring-github-copilot/configuring-github-copilot-in-your-environment?tool=vscode

Upvotes: 2

elulcao
elulcao

Reputation: 478

I got configured NvChad and neovim on my mac, both works amazing. I you didn't modify the default Copilot key map TAB then you should be fine following the recommendations for the Copilot plugin.

I use OPT + [ or OPT + ] for the suggestion, or TAB for current suggestion.

: help Copilot

The argument to copilot#Accept() is the fallback for when no suggestion is
displayed.  In this example, a regular carriage return is used.  If no
fallback is desired, use an argument of "" (an empty string).

Other Maps  

                                                *copilot-i_CTRL-]*
<C-]>                   Dismiss the current suggestion.
<Plug>(copilot-dismiss)

                                                *copilot-i_ALT-]*
<M-]>                   Cycle to the next suggestion, if one is available.
<Plug>(copilot-next)

                                                *copilot-i_ALT-[*
<M-[>                   Cycle to the previous suggestion.
<Plug>(copilot-previous)

                                                *copilot-i_ALT-\*
<M-\>                   Explicitly request a suggestion, even if Copilot
<Plug>(copilot-suggest) is disabled.

Upvotes: 0

Bertrand
Bertrand

Reputation: 447

You should just update the shortcut.

In pycharm, webstorm.... : go to "Preference" > "Keymap" and look for "Copilot: show previous /next completion" and add your custom keyboard shortcut.

Upvotes: 8

user3522717
user3522717

Reputation: 11

I have tried this in VScode. You can use

Option+\

to trigger the first suggestion then use next and prev shortcuts to cycle through the suggestion

Upvotes: 1

Ufukcan Eski
Ufukcan Eski

Reputation: 166

For Visual Studio Code

Manage -> Keyboard Shortcuts

search for these two expressions; Previous

editor.action.inlineSuggest.showPrevious

Next

editor.action.inlineSuggest.showNext

Decide which shortcuts you want to put.

Congrats it's working now.

Upvotes: 15

gkford
gkford

Reputation: 371

I thought I had this problem.

It turned out that the current version of copilot simply only had one suggestion in a lot of cases.

You can see if copilot has alternate suggestions by hovering your mouse over the suggestion. For me, in the cases where the keyboard shortcuts 'didn't work', there simply were no other suggestions available.

Upvotes: 37

Related Questions