Ikhodi eku-inthanethi yethuluzi lokuguqula i-Snippet, Sekela i-JavaScript / TypeScript / React / JSX / TSX      

Sicela ufake igama lamazwibela (name)
Sicela ufake isiqalo samazwibela (prefix)
Sicela ufake incazelo yamazwibela (description)
Sicela ufake umbhalo wekhodi (code body)
Uhlobo Lwesizukulwane
Umphumela Wamazwibela Owenziwe

VSCode Ungawasebenzisa kanjani amazwibela ekhodi


Snippets in Visual Studio Code
Amazwibela we-VS Code ayindlela enamandla yokuthuthukisa umkhiqizo wakho wokubhala ngekhodi ngokuzenzakalelayo ukufakwa kwamabhulokhi ekhodi asetshenziswa kakhulu. Kungaba ukunwetshwa kombhalo okulula noma izifanekiso eziyinkimbinkimbi kakhulu ezinezibambi zendawo nokuguquguqukayo. Nansi indlela yokuwasebenzisa:

Ukudala amazwibela:

Finyelela Izilungiselelo Ze-Snippet: Iya kokuthi Ifayela> Izintandokazi> Amazwibela Womsebenzisi (Ikhodi> Okuncanyelwayo> Amazwibela Womsebenzisi ku-macOS). Noma, sebenzisa iphalethi yomyalo (Ctrl+Shift+P noma Cmd+Shift+P) bese uthayipha "Izintandokazi: Lungiselela Amazwibela Womsebenzisi".

Khetha Ulimi: Uzoyalelwa ukuthi ukhethe ulimi lwamazwibela akho (isb., javascript.json, python.json, njll.). Lokhu kuqinisekisa ukuthi amazwibela atholakala kuphela kulolo limi oluthile. Ungakwazi futhi ukudala ifayela elithi "Global Snippets" uma ufuna amazwibela afinyeleleke kuzo zonke izilimi.

Chaza Amazwibela: Amazwibela achazwa ngefomethi ye-JSON. Amazwibela ngamunye anegama, isiqalo (isinqamuleli ozosithayipha ukuze uqalise amazwibela), umzimba (ikhodi okufanele ifakwe), kanye nencazelo oyikhethayo.

Isibonelo (i-JavaScript):
{
  "For Loop": {
    "prefix": "forl",
    "body": [
      "for (let i = 0; i < $1; i++) {",
      "  $0",
      "}"
    ],
    "description": "For loop with index"
  }
}
Kulesi sibonelo:

"For Loop": Igama lamazwibela (ngokwereferensi yakho).
"forl": Isiqalo. Ukuthayipha okuthi "forl" nokucindezela okuthi Tab kuzofaka amazwibela.
"umzimba": Ikhodi okufanele uyifake. $1, $2, njll. amathebhu (izibambindawo). $0 indawo yokugcina yekhesa.
"incazelo": Incazelo yokuzikhethela eboniswe kuziphakamiso ze-IntelliSense.
Ukusebenzisa amazwibela:

Thayipha Isiqalo: Efayeleni lohlobo lolimi olulungile, qala ukuthayipha isiqalo osichazile (isb., forl).

Khetha i-Snippet: I-IntelliSense ye-VS Code izophakamisa amazwibela. Ikhethe ngokhiye bemicibisholo noma ngokuchofoza.

Sebenzisa Izitobhu: Cindezela okuthi Tab ukuze uzulazule phakathi kwezitobhi ($1, $2, njll.) bese ugcwalisa amanani.

Okuguquguqukayo:

Amazwibela angaphinda asebenzise okuhlukile okufana ne-$TM_FILENAME, $CURRENT_YEAR, njll. Ukuze uthole uhlu olugcwele, bona imibhalo ye-VS Code.

Isibonelo esinezinto eziguquguqukayo (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}"
    ]
  }
}
Ngokwazi amazwibela, unganciphisa kakhulu ukuthayipha okuphindaphindayo futhi uqinisekise ukuvumelana kwekhodi yakho. Linga ngokudala amazwibela akho ukuze uthole amaphethini ekhodi avame ukusetshenziswa futhi ubuke ukusebenza kahle kokubhala kwakho kukhuphuka.