Ikhowudi ye-Intanethi kwisixhobo sokuguqula iSnippet, Inkxaso yeJavaScript / TypeScript / React / JSX / TSX      

Nceda ngenisa isiqwengana igama (name)
Nceda ngenisa isiqwengana sokuqala (prefix)
Nceda ngenisa inkcazo yesiqwengana (description)
Nceda ngenisa umbhalo wekhowudi (code body)
Uhlobo lwesiZukulwana
Isiphumo seSnippet esiveliswe

VSCode Uzisebenzisa njani iziqwengana zekhowudi


Snippets in Visual Studio Code
Iziqwengana zeKhowudi ye-VS yindlela enamandla yokunyusa imveliso yakho yekhowudi ngokwenza ngokuzenzekelayo ukufakela iibhloko zekhowudi ezisetyenziswa ngokuqhelekileyo. Zisenokuba lulwandiso lombhalo olulula okanye itemplates ezintsonkothileyo ezinezibambi-ndawo kunye nezinto eziguquguqukayo. Nantsi indlela yokuzisebenzisa:

Ukwenza iziqwengana:

Ukufikelela kuseto lwe-Snippet: Yiya kwiFayile> Okukhethwayo> Iziqwengana zabasebenzisi (Ikhowudi> Okukhethwayo> Iziqwengana zomsebenzisi kwi-macOS). Kungenjalo, sebenzisa i-palette yomyalelo (Ctrl+Shift+P okanye Cmd+Shift+P) kwaye uthayiphe "Ezikhethwayo: Qwalasela ii-Snippets zomsebenzisi".

Khetha ulwimi: Uya kucelwa ukuba ukhethe ulwimi lwesnippet yakho (umzekelo, javascript.json, python.json, njl.). Oku kuqinisekisa ukuba i-snippet ifumaneka kuphela ngolo lwimi lukhethekileyo. Unokwenza kwakhona ifayile ye "Global Snippets" ukuba ufuna i-snippet ifikeleleke kuzo zonke iilwimi.

Chaza iSnippet: Iziqwengana zichazwe ngefomathi ye-JSON. Isiqwengana ngasinye sinegama, isimaphambili (indlela emfutshane oza kuyichwetheza ukucupha i-snippet), umzimba (ikhowudi efakelwe), kunye nenkcazo ekhethiweyo.

Umzekelo (iJavaScript):
{
  "For Loop": {
    "prefix": "forl",
    "body": [
      "for (let i = 0; i < $1; i++) {",
      "  $0",
      "}"
    ],
    "description": "For loop with index"
  }
}
Kulo mzekelo:

"Ye-Loop": Igama le-snippet (yereferensi yakho).
"forl": Isimaphambili. Ukuchwetheza "forl" kunye nokucofa i-Tab kuya kufaka i-snippet.
"umzimba": Ikhowudi emayifakwe. $1, $2, etc. zii tabstops (izibambi-ndawo). $0 yindawo yokugqibela yekhesa.
"inkcazo": Inkcazo ekhethiweyo eboniswe kwiingcebiso ze-IntelliSense.
Ukusebenzisa iziqwengana:

Chwetheza isimaphambili: Kwifayile yohlobo oluchanekileyo lolwimi, qalisa ukuchwetheza isimaphambili osichazile (umzekelo, forl).

Khetha iSnippet: I-IntelliSense ye-VS Code iya kucebisa i-snippet. Yikhethe ngezitshixo zotolo okanye ngokucofa.

Sebenzisa iiTabstops: Cinezela iTab ukuze uhambe phakathi kwee-tabstops ($1, $2, njl.) kwaye ugcwalise amaxabiso.

Izinto eziguquguqukayo:

Iziqwengana zisenokusebenzisa izinto eziguquguqukayo ezifana ne-$ TM_FILENAME, $CURRENT_YEAR, njl. Ukuze ufumane uluhlu olupheleleyo, jonga amaxwebhu eKhowudi yeVS.

Umzekelo ngeZiguquguquko (Python):
{
  "New Python File": {
    "prefix": "newpy",
    "body": [
      "#!/usr/bin/env python3",
      "# -*- coding: utf-8 -*-",
      "",
      "# ${TM_FILENAME}",
      "# Created by: ${USER} on ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}"
    ]
  }
}
Ngokufunda iziqwengana, unokunciphisa kakhulu ukuphinda uchwetheze kwaye uqinisekise ukuhambelana kwikhowudi yakho. Linga ukwenza iziqwengana zakho zeepatheni zekhowudi ezisetyenziswa ngokuqhelekileyo kwaye ubukele ukusebenza kakuhle kwekhowudi yakho kunyuka.