I manage my snippets in a single MyGlobal.code-snippets
file.
I'd like to restrict individual snippets to show only for certain languages. For example, below snippet should occur only in jsx,tsx files.
"useEffect(() => {\"\"},[]);": {
"prefix": "useEffect",
"body": ["useEffect(() => {", "$0", "},[]);"],
"description": "useEffect(()=>{},[])"
},
According to VSCode docs, we can do that by adding language scope, However, it's not working in my case. If I add scope, it stops occurring in any files including jsx,tsx.
"useEffect(() => {\"\"},[]);": {
"prefix": "useEffect",
"scope": "jsx,tsx",
"body": ["useEffect(() => {", "$0", "},[]);"],
"description": "useEffect(()=>{},[])"
},
I know there's a way to have language-specific snippet files but I prefer to manage all user snippets inside a single file.
CodePudding user response:
use the languageIDs
"useEffect(() => {\"\"},[]);": {
"prefix": "useEffect",
"scope": "javascriptreact,typescriptreact",
"body": ["useEffect(() => {", "$0", "},[]);"],
"description": "useEffect(()=>{},[])"
},