Kode yo kumurongo kubikoresho bya Snippet Igikoresho, Shyigikira JavaScript / TypeScript / Reaction / JSX / TSX
VS Code snippets ninzira ikomeye yo kuzamura umusaruro wa coding ukoresheje guhinduranya kwinjiza bisanzwe bikoreshwa. Birashobora kuba inyandiko yoroshye yo kwagura cyangwa byinshi bigoye inyandikorugero hamwe nabafite imyanya nibihinduka. Dore uburyo bwo kubikoresha:
Gukora uduce:
Injira Igenamiterere Igenamiterere: Jya kuri File> Ibyifuzo> Udukoryo twifashisha (Kode> Ibyifuzo> Udukoryo twinshi kuri macOS). Ubundi, koresha itegeko palette (Ctrl + Shift + P cyangwa Cmd + Shift + P) hanyuma wandike "Ibyifuzo: Hindura uduce duto two gukoresha".
Hitamo Ururimi: Uzasabwa guhitamo ururimi rwigice cyawe (urugero, javascript.json, python.json, nibindi). Ibi byemeza ko ibisobanuro biboneka kuri urwo rurimi rwihariye. Urashobora kandi gukora dosiye "Global Snippets" niba ushaka ko igicapo kiboneka mundimi zose.
Sobanura Igicapo: Ibisobanuro bisobanuwe muburyo bwa JSON. Igice cyose gifite izina, imbanzirizamushinga (shortcut uzandika kugirango utere uduce), umubiri (kode igomba kwinjizwamo), nibisobanuro bidahwitse.
Urugero (JavaScript):
{
"For Loop": {
"prefix": "forl",
"body": [
"for (let i = 0; i < $1; i++) {",
" $0",
"}"
],
"description": "For loop with index"
}
}
Muri uru rugero:
"Kuri Loop": Izina ry'igice (kugirango ubone).
"forl": imbanzirizamushinga. Kwandika "forl" no gukanda Tab bizashyiramo agace.
"umubiri": Kode yo gushiramo. $ 1, $ 2, nibindi ni tabstops (abafite umwanya). $ 0 nu mwanya wanyuma indanga.
"ibisobanuro": Ibisobanuro bidahwitse byerekanwe mubyifuzo bya IntelliSense.
Gukoresha uduce:
Andika imbanzirizamushinga: Muri dosiye yubwoko bwururimi rwukuri, tangira wandike prefix wasobanuye (urugero, forl).
Hitamo Igice: IntelliSense ya VS Code izerekana ibisobanuro. Hitamo ukoresheje urufunguzo rw'imyambi cyangwa ukanze.
Koresha Tabstops: Kanda Tab kugirango uyobore hagati ya tabstops ($ 1, $ 2, nibindi) hanyuma wuzuze indangagaciro.
Ibihinduka:
Igicapo kirashobora kandi gukoresha impinduka nka $ TM_FILENAME, $ CURRENT_YEAR, nibindi. Kurutonde rwuzuye, reba inyandiko ya VS Code.
Urugero hamwe nibihinduka (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}"
]
}
}
Ukoresheje uduce duto, urashobora kugabanya cyane kwandika inshuro nyinshi kandi ukemeza ko kode yawe ihoraho. Iperereza ryo gukora uduce twawe bwite kubisanzwe bikoreshwa kode hanyuma urebe imikorere yawe ya code.