Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tab is conflicting intellisense and snippets in vs code

I want to use a 'for' snippet for example. I write for and press tab twice so it autocompletes to the whole for loop and selects the counter so I can change it. I change that and then press tab to go to next variable(the one 'counter < [here]' in the condition statement). Then the problem is i write 'arr' and it autocompletes to something like 'ANGLE_instanced_arrays'. I want to just write 'arr' then press tab to go to next variable in the loop, BUT if I press tab it autocompletes. Any solutions?

like image 364
Kys Plox Avatar asked Dec 27 '16 15:12

Kys Plox


People also ask

How do I fix VS Code IntelliSense?

Troubleshooting. If you find IntelliSense has stopped working, the language service may not be running. Try restarting VS Code and this should solve the issue. If you are still missing IntelliSense features after installing a language extension, open an issue in the repository of the language extension.

Why are snippets not working in VS Code?

Problems with IntelliSense code snippets are typically caused by two problems: a corrupt snippet file or bad content in the snippet file.


3 Answers

I created an account specifically to answer this question because it's such an annoying problem :)

Add the following to your keybindings.json:

{"key": "tab", "command": "-acceptSelectedSuggestion", "when": "editorTextFocus && suggestWidgetVisible"},    
{"key": "tab", "command": "acceptSelectedSuggestion", "when": "editorTextFocus && suggestWidgetVisible && !inSnippetMode" },    

The first line disables the existing rule, the second line re-enables it unless you're in snippet mode.

like image 194
Adam Shone Avatar answered Nov 01 '22 15:11

Adam Shone


this is my keybindings.json press tab to go to next variable in the loop ctrl+p go to the previous one

[  
    {   
      "key": "tab",               
      "command": "selectNextSuggestion",  
      "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" },  
    {  
      "key": "ctrl+p",                    
      "command": "selectPrevSuggestion",  
      "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" },  
]
like image 25
rainyluo Avatar answered Nov 01 '22 15:11

rainyluo


What you can do is to disable accepting suggestions on tab and to enable pure tabCompletion. The respective settings are "editor.acceptSuggestionOnEnter": false and "editor.tabCompletion": true. With those settings you can complete snippets, like for just with tab (no IntelliSense pop up) and when IntelliSense shows suggestions can be accepted with enter only

like image 32
Johannes Rieken Avatar answered Nov 01 '22 15:11

Johannes Rieken