Esaleli ya kobongola code na fragment en ligne, kosunga JavaScript / TypeScript / React / JSX / TSX      

Svp kotia kombo ya fragment (name)
Svp kotia liboso ya mwa ndambo (prefix)
Svp kotia ndimbola ya mwa ndambo (description)
Svp kotia makomi ya code (code body)
Lolenge ya nkola
Résultat ya Fraglement oyo esalemi

VSCode Ndenge ya kosalela ba fragments ya code


Snippets in Visual Studio Code
VS Code snippets ezali lolenge ya makasi ya kotombola productivité ya codage na yo na ko automatiser insertion ya ba blocs ya code oyo esalemaka mingi. Ekoki kozala ba expansions simples ya texte to ba modèles complexes mingi na ba placeholders na ba variables. Tala ndenge ya ko leverage bango:

Kosala ba Fragments:

Kokota na Paramètres ya ba fragments: Kende na Fichier > Ba préférences > Ba fragments ya mosaleli (Code > Ba préférences > Ba fragments ya mosaleli na macOS). Na lolenge mosusu, salela palette ya komande (Ctrl+Shift+P to Cmd+Shift+P) mpe koma "Préférences: Configurer ba fragments ya mosaleli".

Pona monoko: Bakosenga yo pona monoko pona fragment na yo (e.g., javascript.json, python.json, etc.). Yango esalaka ete mwa ndambo yango ezala kaka mpo na monɔkɔ wana ya sikisiki. Okoki pe kosala fichier "Global Snippets" soki olingi snippet ezala accessible na minoko nionso.

Limbola Eteni: Biteni elimbolami na format JSON. Eteni moko na moko ezali na nkombo, liboso (nzela mokuse oyo okokoma mpo na kofungola eteni), nzoto (code oyo esengeli kokɔtisa), mpe ndimbola oyo okoki kopona.

Ndakisa (JavaScript):
{
  "For Loop": {
    "prefix": "forl",
    "body": [
      "for (let i = 0; i < $1; i++) {",
      "  $0",
      "}"
    ],
    "description": "For loop with index"
  }
}
Na ndakisa oyo:

"For Loop": Nkombo ya fragment (mpo na référence na yo).
"forl": Liloba ya liboso. Kokoma "forl" mpe kofina Tab ekotia fragment.
"nzoto": Code ya kokotisa. $1, $2, etc. ezali ba onglets (ba placeholders). $0 ezali esika ya suka ya curseur.
"description": Bolimbisi ya boponi oyo elakisami na makanisi ya IntelliSense.
Kosalela Biteni ya Biteni:

Tyá Liboso: Na fisyé ya lolenge ya monɔkɔ oyo ebongi, banda kokoma liboso oyo olimboli (e.g., forl).

Pona Eteni: IntelliSense ya VS Code ekopesa likanisi ya eteni. Poná yango na bafɔtɔ ya flèche to na kofinaka.

Salelá ba onglets: Finá Onglet mpo na kotambola kati na ba onglets ($1, $2, mpe bongo na bongo) mpe kotondisa ba valeurs.

Ba variables: 1.1.

Ba fragments ekoki pe kosalela ba variables lokola $TM_FILENAME, $CURRENT_YEAR, etc. Mpo na liste mobimba, tala mikanda ya Code VS.

Ndakisa na ba Variables (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}"
    ]
  }
}
Na koyebaka malamu biteni, okoki kokitisa mpenza kokoma mbala na mbala mpe kosala ete code na yo ezala na boyokani. Meká kosala biteni na yo moko mpo na ba modèles ya code oyo esalelamaka mingi mpe tala efficacité na yo ya codage komata.