1234567891011121314151617181920212223242526272829303132333435 |
- {
- // man page: https://code.visualstudio.com/docs/editor/userdefinedsnippets
- // Place your snippets for qsp here. Each snippet is defined under a snippet name and has a prefix, body and
- // description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
- // $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
- // same ids are connected.
- // Example:
- // "Print to console": {
- // "prefix": "log",
- // "body": [
- // "console.log('$1');",
- // "$2"
- // ],
- // "description": "Log output to console"
- // }
- "Loop": {
- "prefix": ["loop", "for", "foreach", "jump"],
- "body": [
- "!! A snippet to loop through an array. Rename the variables accordingly.",
- "!! Use [Tab] to rename the next var. [Esc] to abort renaming. This comment section can be deleted.",
- "!! ${1:arrayName}: the name of the array thats gets run through",
- "!! ${2:tmp${TM_FILENAME_BASE/[\\.-]/_/g}${TM_LINE_NUMBER}Idx}: this is the index variable and should be unique for the loop",
- "!! \t\tand since it gets killed make sure not to override another var",
- "!! ${3:${TM_FILENAME_BASE/[\\.-]/_/g}${TM_LINE_NUMBER}}: this is the jump name and should be unique for the file,",
- "$2 = 0",
- ":$3",
- "if $2 < arrsize('$1'):",
- "\t$1[$2]${0}",
- "\t$2+=1",
- "\tjump '$3'",
- "end",
- "killvar '$2'"],
- "description": "Loop through an array."
- }
- }
|