qsp.json 1.5 KB

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