Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keyboard shortcuts to choose an intellisense suggestion? #24918

Closed
suan opened this issue Apr 17, 2017 · 6 comments
Closed

keyboard shortcuts to choose an intellisense suggestion? #24918

suan opened this issue Apr 17, 2017 · 6 comments
Assignees
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code suggest IntelliSense, Auto Complete
Milestone

Comments

@suan
Copy link

suan commented Apr 17, 2017

Was abit surprised that the intellisense suggestions weren't keyed with a number or something where the user could say Ctrl+5 and choose the fifth suggestion - has this been considered?

@rebornix
Copy link
Member

Nice suggestion, we can enhance it by adding args to selectPrevSuggestion.

@rebornix rebornix added the feature-request Request for new features or functionality label Apr 17, 2017
@mjbvz mjbvz added the suggest IntelliSense, Auto Complete label Nov 3, 2017
@octref octref self-assigned this Sep 9, 2019
@octref octref added this to the September 2019 milestone Sep 9, 2019
@octref
Copy link
Contributor

octref commented Sep 24, 2019

I tried two approaches:

  1. Alt 1-9 focuses completion item 1-9. But I feel it should also insert the chosen completion (as echoed by @matklad in First PR: Adding jump to nth autocomplete suggestion via keyboard shortcut #58670 (comment))
  2. Below (temporary icons, subject to change):

alt

However, some of the team feel it's easier to just type out the suggestion and filter the items & don't think we should add such functionality.

@octref octref modified the milestones: September 2019, Backlog Sep 24, 2019
@matklad
Copy link

matklad commented Feb 19, 2020

I've realized that I'd love to use the same ctrl+N shortuct to select code actions:

image

This is probably not possible right now implementation wise, because actions use a native context menu; but, as a user, I would appreciate such feature.

@jrieken jrieken assigned jrieken and unassigned octref May 6, 2020
@ChrisThackrey
Copy link

Is the source code for this feature still available?

@jrieken jrieken added the *out-of-scope Posted issue is not in scope of VS Code label Oct 26, 2020
@ouweiya
Copy link

ouweiya commented Oct 10, 2021

When popping up a list of smart tips, I often use upArrow and downArrow to skip to the previous or next suggestion. I use tab and shift+tab instead.

I use tab and shift+tab to quickly switch to a prompt, and use ctrl+tab to complete the prompt.

  {
    "key": "tab",
    "command": "selectNextSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "shift+tab",
    "command": "selectPrevSuggestion",
    "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
  },
  {
    "key": "ctrl+tab",
    "command": "acceptSelectedSuggestion",
    "when": "acceptSuggestionOnEnter && suggestWidgetVisible && suggestionMakesTextEdit && textInputFocus"
  }

@CharlieYu1
Copy link

CharlieYu1 commented Nov 15, 2023

I made the following keybindings to my keybindings.js. Maybe I should make this into an extension.

// Place your key bindings in this file to override the defaults
[
    {
        "key": "ctrl+1",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+2",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+3",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+4",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+5",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+6",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+7",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+8",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+9",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectFirstSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "selectNextSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
    {
        "key": "ctrl+0",
        "command": "runCommands",
        "args": {
            "commands": [
                "selectLastSuggestion",
                "acceptSelectedSuggestion"
            ]
        },
        "when": "suggestWidgetMultipleSuggestions && suggestWidgetVisible && textInputFocus"
    },
]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request Request for new features or functionality *out-of-scope Posted issue is not in scope of VS Code suggest IntelliSense, Auto Complete
Projects
None yet
Development

No branches or pull requests

10 participants