Keyboard shortcut to turn autocomplete on and off

Is there a way to turn autocomplete on and off with a keyboard shortcut?

Since for those of us who are practicing python for example, many times we do not want it to show us how to do something, but rather do it ourselves. On the other hand, autocomplete is still very useful to create documentation, comments and things like lists quickly and be more productive when practicing, so I think a quick way to activate and deactivate autocomplete would be great

Hi @Enzopin ,

Does this assist?

I’m doing this in keybindings.json:

  {
    "key": "ctrl+shift+x",
    "command": "editor.cpp.disableenabled"
  },
  {
    "key": "ctrl+shift+c",
    "command": "editor.action.enableCppGlobally"
  }

Seems to be working. I wish cmd shift x would toggle but I’m not sure the when statement value that would check the cpp enabled state

2 Likes

I would personally love it if I could disable autocomplete suggestions for editing regular text, but get suggestions for code. It’s hard to think while writing when the editor keeps suggesting text.

To set a keybinding for this:

  1. Type Command/Ctrl + Shift + P.
  2. Go to “preferences: open keyboard shortcuts”
  3. Search ‘cursor tab’
  4. Set an enable hotkey and a disable hotkey.

No option to have a single hotkey that toggles ASAIK.

You might be able to accomplish this using the setting described here:

It’d be great if you could set a single key for toggle, rather than having to have a different key for enable and disable.

Please teach a man how to fish - where did you find these command names?

When you assign a key combination, it shows up in the JSON file.

@mbylst I’ve been looking for the same thing - a single-key shortcut to quickly disable the mighty cursor tab when it’s doing too much and starts editing the code around the cursor when I’m just trying to fix some indentations.

Since I couldn’t find anything online, I tried to come up with my own solution. Maybe it’s not the most elegant way to do it, but I tied so many different things and this was the only thing that actually worked in the end.

Here’s the setup:
First we need extensions, so hit Ctrl+Shift+X and in the marketplace find and install these two:
“Settings Cycler” by hoovercj
“multi-command” by ryuta46

A couple lines of code in the user settings.json and keybindings.json.

settings.json:

{
    // ... other settings ...
    "cursor.cmdk.useThemedDiffBackground": true,
    "settings.cycle": [
        {
            "id": "toggleCursorTabSet_disable",
            "values": [{
                    "cursor.cmdk.useThemedDiffBackground": false,
                    "editor.cursorStyle": "line-thin"
            }]
        },
        {
            "id": "toggleCursorTabSet_enable",
            "values": [{
                    "cursor.cmdk.useThemedDiffBackground": true,
                    "editor.cursorStyle": "line"
            }]
        }
    ],
    "multiCommand.commands": [
        {
            "command": "multiCommand.toggleCursorTabEnable",
            "sequence": [
                "editor.action.enableCppGlobally",
                "settings.cycle.toggleCursorTabSet_enable"
            ]
        },
        {
            "command": "multiCommand.toggleCursorTabDisable",
            "sequence": [
                "editor.cpp.disableenabled",
                "settings.cycle.toggleCursorTabSet_disable"
            ]
        }
    ]
}

keybindings.json:

[
    // ... other keybindings ...
    // this is optional : removes the default keybinding for ctrl+tab
    {
        "key": "ctrl+tab",
        "command": "-workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup",
        "when": "!activeEditorGroupEmpty"
    },
    // cursor tab toggle keybindings
    {
        "key": "ctrl+tab",
        "command": "multiCommand.toggleCursorTabEnable",
        "when": "!config.cursor.cmdk.useThemedDiffBackground"
    },
    {
        "key": "ctrl+tab",
        "command": "multiCommand.toggleCursorTabDisable",
        "when": "config.cursor.cmdk.useThemedDiffBackground"
    }
]

Don’t forget to remove any other keybindings for ‘Ctrl+Tab’ or choose an alternative shortcut that isn’t already in used.

That should do the trick! :slightly_smiling_face:
By the way, I chose the ‘cursor.cmdk.useThemedDiffBackground’ setting to store the toggle state, as it doesn’t seem to have much impact anyway. It’s a bit messy, but hey… it works! You could also replace it with a different boolean key-value in settings.json. It’s necessary for the when-condition in the keybindings.

4 Likes

This worked for me - thank you!

Thanks for this. It works in that I can more easily turn off (and sometimes when I am feeling hopeful - turn on) this feature.

It is a pity that one of Cursor’s main features needs to be turned off half the time.
I am confident if they allow us to configure the key for the tragically named Cursor Tab then we will appreciate more when we need it.
Seeing a great autocomplete suggestion and choosing it is a much better user experience than accidentally hitting tab for all the other reasons we have to hit tab and then having to figure out wtf cursor just did. That is not a feature.


I know I can enable/disable “cursor tabs”, but I need more fine-grained control logic

  1. Is there a way to actively trigger “cursor suggestions”? When the “cursor tab” is “enable”, I always have to wait a few seconds for the suggestions to appear. During this period, I can’t confirm whether the “cursor tab” is working properly (is there a network problem or the cursor ta is not triggered at all?), I hope that a suggestion will be triggered when I press a “keyboard shortcuts”
  2. Is there a way to switch the shortcut key for accepting “curse suggestions” from “tab” to other keys? I like to “tab” all the way, but I have to say that I need to fight for control with it in many cases (especially when tab is also a commonly used auto-completion shortcut key, I don’t want to change my usage habits for a new feature: switch the “accept suggestions of vs code” to “Enter”)

1 Like

I tried this just now and it works like a charm! Wow. I have my tab back :folded_hands: and I can use one of the best features as a bonus!

1 Like