VS Code Intellisense don't suggest snippet at first

后端 未结 4 1330
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-31 07:52

I want to use code snippets in VSCode. But when I type, for example, for in javascript file, the Intellisense doesn\'t suggest snippet \"for-loop\" - I need to manu

相关标签:
4条回答
  • 2021-01-31 08:30

    Setting editor.snippetSuggestions to top only works for certain snippets: for but not foreach. With top, the snippet does appear higher in the completion list, but for some reason the keyword version is what is highlighted, with the snippet option scrolled out of view (and the scrollbar quickly fades, giving the impression there's nothing hidden)

    The editor.tabCompletion to true approach works for both for and foreach.

    0 讨论(0)
  • 2021-01-31 08:40

    There is one more way to deal with this issue by setting "editor.tabCompletion": true, that way whenever there is a snnipet available it will use it automatically without even opening the list by using tab twice.

    1. File > Preferences > Settings (Code > Preferences > Settings on Mac)
    2. open "Editor" menu on the left
    3. edit "editor.tabCompletion": true

    more info: https://code.visualstudio.com/docs/editor/intellisense#_customizing-intellisense

    0 讨论(0)
  • 2021-01-31 08:45

    Now that VS Code mostly abstracted away the settings.json file, you can do the instructions shown by Kavu, with this bonus tip:

    • go to Preferences > Settings

    • find the Search settings text input, at the top

    • type in "snippet"

    The setting should be at the top of the result set:

    0 讨论(0)
  • 2021-01-31 08:47

    You need to use editor.snippetSuggestions config option with "top" value. Please, see Customizing IntelliSense article for more tips and tricks.

    0 讨论(0)
提交回复
热议问题