How to edit existing VS Code Snippets

前端 未结 5 1223
渐次进展
渐次进展 2020-11-30 04:04

Is there a way to remove or edit some of the default code snippets in Visual Studio CODE ?

For example when i type req+TAB i need require not requ

5条回答
  •  暖寄归人
    2020-11-30 04:12

    The extensions snippets can be found inside each snippet directory below:
    (if there are snippets in the extension)

    Mac/Linux: $HOME/.vscode/extensions/
    Windows: %USERPROFILE%\.vscode\extensions/

    Select the extension you want to modify and then dive into the javascript.json file in snippets/ directory in there, and change whatever you like.

    Just remember that if/when you choose to download and update the extension someday, all your personal modifications will get overwritten/replaced out with the updated version of the file. (unless of course you squirrel away your changes outside of the extension's directory...)

    Edit/Aside: Looking closely at all the copied editions already present in this directory, it appears that at least some of the extension updates keep the former version around. If this is the case, when you update an extension when a new version is released, you wouldn't need to worry about storing a copy of your modified file somewhere else; returning a file to active duty might just be as easy as a copy-paste from the old into the appropriate, newer, higher numbered directory.

    Resources/citations/acknowledgements:
    Thanks to here for helping initially pointing me towards the relevant directory.

提交回复
热议问题