tcl.snippets 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. # #!/usr/bin/env tclsh
  2. snippet #!
  3. #!/usr/bin/env tclsh
  4. # Process
  5. snippet pro
  6. proc ${1:function_name} {${2:args}} {
  7. ${3:#body ...}
  8. }
  9. #xif
  10. snippet xif
  11. ${1:expr}? ${2:true} : ${3:false}
  12. # Conditional
  13. snippet if
  14. if {${1}} {
  15. ${2:# body...}
  16. }
  17. # Conditional if..else
  18. snippet ife
  19. if {${1}} {
  20. ${2:# body...}
  21. } else {
  22. ${3:# else...}
  23. }
  24. # Conditional if..elsif..else
  25. snippet ifee
  26. if {${1}} {
  27. ${2:# body...}
  28. } elseif {${3}} {
  29. ${4:# elsif...}
  30. } else {
  31. ${5:# else...}
  32. }
  33. # If catch then
  34. snippet ifc
  35. if { [catch {${1:#do something...}} ${2:err}] } {
  36. ${3:# handle failure...}
  37. }
  38. # Catch
  39. snippet catch
  40. catch {${1}} ${2:err} ${3:options}
  41. # While Loop
  42. snippet wh
  43. while {${1}} {
  44. ${2:# body...}
  45. }
  46. # For Loop
  47. snippet for
  48. for {set ${2:var} 0} {$$2 < ${1:count}} {${3:incr} $2} {
  49. ${4:# body...}
  50. }
  51. # Foreach Loop
  52. snippet fore
  53. foreach ${1:x} {${2:#list}} {
  54. ${3:# body...}
  55. }
  56. # after ms script...
  57. snippet af
  58. after ${1:ms} ${2:#do something}
  59. # after cancel id
  60. snippet afc
  61. after cancel ${1:id or script}
  62. # after idle
  63. snippet afi
  64. after idle ${1:script}
  65. # after info id
  66. snippet afin
  67. after info ${1:id}
  68. # Expr
  69. snippet exp
  70. expr {${1:#expression here}}
  71. # Switch
  72. snippet sw
  73. switch ${1:var} {
  74. ${3:pattern 1} {
  75. ${4:#do something}
  76. }
  77. default {
  78. ${2:#do something}
  79. }
  80. }
  81. # Case
  82. snippet ca
  83. ${1:pattern} {
  84. ${2:#do something}
  85. }${3}
  86. # Namespace eval
  87. snippet ns
  88. namespace eval ${1:path} {${2:#script...}}
  89. # Namespace current
  90. snippet nsc
  91. namespace current