├── LICENSE ├── README.md └── latex.hsnips /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Snippets for VSCode with HyperSnips 2 | 3 | This repository provides snippet configurations for 4 | [HyperSnips extension](https://github.com/draivin/hsnips), 5 | which is a powerful snippet tool for Visual Studio Code (VSCode). 6 | 7 | ## How to install 8 | 9 | 1. Open a directory for HyperSnips with the command `HyperSnips: Open snippets directory` 10 | 2. Make copies (or symbolic links) of snippet files of this repo in the directory 11 | 12 | 13 | ## LaTeX 14 | File: [latex.hsnips](./latex.hsnips) 15 | 16 | This configuration is inspired by [Obsidian Latex Suite](https://github.com/artisticat1/obsidian-latex-suite), 17 | which is based on the [Gilles Castel's setup using UltiSnips](https://castel.dev/post/lecture-notes-1/). 18 | The function for math context is defined with reference to [this comment](https://github.com/draivin/hsnips/issues/107#issuecomment-1021000711), and the snippets for fractions are based on [here](https://stackoverflow.com/questions/62545965/latex-fraction-snippets-in-vscode) and [here](https://github.com/draivin/hsnips/issues/18). 19 | 20 | -------------------------------------------------------------------------------- /latex.hsnips: -------------------------------------------------------------------------------- 1 | global 2 | function math(context) { 3 | return context.scopes.some( 4 | s => s.startsWith("meta.math") 5 | ) 6 | && !context.scopes.some( 7 | s => ( 8 | s.startsWith("comment") 9 | || s.startsWith("meta.definition.label") 10 | || s.startsWith("meta.reference.label") 11 | || s.startsWith("meta.text.normal.tex") 12 | ) 13 | ); 14 | } 15 | endglobal 16 | 17 | 18 | ############################################################################## 19 | # Math mode 20 | ############################################################################## 21 | snippet ;; "Inline math" iA 22 | \$$0\$ 23 | endsnippet 24 | 25 | snippet dm "Display math" A 26 | \begin{align} 27 | $0 28 | \end{align} 29 | endsnippet 30 | 31 | 32 | ############################################################################## 33 | # Operations 34 | ############################################################################## 35 | context math(context) 36 | snippet te "text" 37 | \text{$0} 38 | endsnippet 39 | 40 | context math(context) 41 | snippet text "text" Aw 42 | \text{$0} 43 | endsnippet 44 | 45 | context math(context) 46 | snippet bf "math bold" Ai 47 | \mathbf{$0} 48 | endsnippet 49 | 50 | context math(context) 51 | snippet `([ ]*)sr` "squared" Ai 52 | ^{2} 53 | endsnippet 54 | 55 | context math(context) 56 | snippet `([ ]*)cb` "cubed" Ai 57 | ^{3} 58 | endsnippet 59 | 60 | context math(context) 61 | snippet `([ ]*)invs` "inverse" Ai 62 | ^{-1} 63 | endsnippet 64 | 65 | context math(context) 66 | snippet `([ ]*)sp` "superscript" Ai 67 | ^{$1}$0 68 | endsnippet 69 | 70 | context math(context) 71 | snippet _ "subscript" Ai 72 | _{$1}$0 73 | endsnippet 74 | 75 | context math(context) 76 | snippet `([ ]*)sb` "subscript" Ai 77 | _{$1}$0 78 | endsnippet 79 | 80 | context math(context) 81 | snippet `([a-zA-Z])no` "subscript nought" A 82 | ``rv = m[1]``_{\text{0}} 83 | endsnippet 84 | 85 | context math(context) 86 | snippet sq "square root" Ai 87 | \sqrt{$1}$0 88 | endsnippet 89 | 90 | context math(context) 91 | snippet ee "exp (superscript)" Ai 92 | e^{ $1 }$0 93 | endsnippet 94 | 95 | context math(context) 96 | snippet `([^no])rm` "roman" Ai 97 | ``rv = m[1]``\mathrm{$1}$0 98 | endsnippet 99 | 100 | context math(context) 101 | snippet `([ ]*)trans` "transpose" Ai 102 | ^\top 103 | endsnippet 104 | 105 | context math(context) 106 | snippet `([ ]*)conj` "conjugate" Ai 107 | ^* 108 | endsnippet 109 | 110 | context math(context) 111 | snippet Tr "trace" Ai 112 | \Tr 113 | endsnippet 114 | 115 | context math(context) 116 | snippet det "determinant" Ai 117 | \det 118 | endsnippet 119 | 120 | context math(context) 121 | snippet re "real part" A 122 | \Re 123 | endsnippet 124 | 125 | context math(context) 126 | snippet im "imaginary part" A 127 | \Im 128 | endsnippet 129 | 130 | context math(context) 131 | snippet `([a-zA-Z]),\.` "bold style" Ai 132 | \mathbf{``rv = m[1]``} 133 | endsnippet 134 | 135 | context math(context) 136 | snippet `([a-zA-Z])\.,` "bold style (alt)" Ai 137 | \mathbf{``rv = m[1]``} 138 | endsnippet 139 | 140 | context math(context) 141 | snippet `([a-zA-Z]),,` "slant bold style" Ai 142 | \boldsymbol{``rv = m[1]``} 143 | endsnippet 144 | 145 | context math(context) 146 | snippet ,s "slant bold style" Ai 147 | \boldsymbol{$1}$0 148 | endsnippet 149 | 150 | context math(context) 151 | snippet `\b([a-zA-Z])(\d)` "sub number" A 152 | ``rv = m[1]``_{``rv = m[2]``} 153 | endsnippet 154 | 155 | context math(context) 156 | snippet `([a-zA-Z])_(\d\d)` "sub two numbers" Ai 157 | ``rv = m[1]``_{``rv = m[2]``} 158 | endsnippet 159 | 160 | context math(context) 161 | snippet `\\hat{([a-zA-Z])}(\d)` "hat with sub number" Ai 162 | \hat{``rv = m[1]``}_{``rv = m[2]``} 163 | endsnippet 164 | 165 | context math(context) 166 | snippet `\\mathbf{([a-zA-Z])}(\d)` "bold symbol with sub number" Ai 167 | \mathbf{``rv = m[1]``}_{``rv = m[2]``} 168 | endsnippet 169 | 170 | context math(context) 171 | snippet `\\vec{([a-zA-Z])}(\d)` "vec with sub number" Ai 172 | \vec{``rv = m[1]``}_{``rv = m[2]``} 173 | endsnippet 174 | 175 | context math(context) 176 | snippet `([a-gi-zA-Z])bar` "add bar" Ai 177 | \bar{``rv = m[1]``} 178 | endsnippet 179 | 180 | context math(context) 181 | snippet `([a-zA-Z])hat` "add hat" Ai 182 | \hat{``rv = m[1]``} 183 | endsnippet 184 | 185 | context math(context) 186 | snippet `([a-zA-Z])ddot` "add ddot" A 187 | \ddot{``rv = m[1]``} 188 | endsnippet 189 | 190 | context math(context) 191 | snippet `([a-ce-zA-Z])dot` "add dot" Ai 192 | \dot{``rv = m[1]``} 193 | endsnippet 194 | 195 | context math(context) 196 | snippet `([a-zA-Z])vec` "vec" Ai 197 | \vec{``rv = m[1]``} 198 | endsnippet 199 | 200 | context math(context) 201 | snippet `([a-zA-Z])tilde` "add tilde" Ai 202 | \tilde{``rv = m[1]``} 203 | endsnippet 204 | 205 | context math(context) 206 | snippet `([a-zA-Z])und` "add underline" Ai 207 | \underline{``rv = m[1]``} 208 | endsnippet 209 | 210 | context math(context) 211 | snippet bar "bar" Ai 212 | \bar{$1}$0 213 | endsnippet 214 | 215 | context math(context) 216 | snippet hat "hat" Ai 217 | \hat{$1}$0 218 | endsnippet 219 | 220 | context math(context) 221 | snippet Hat "wide hat" Ai 222 | \widehat{$1}$0 223 | endsnippet 224 | 225 | context math(context) 226 | snippet `\\dot` "dot" Ai 227 | \dot{$1}$0 228 | endsnippet 229 | 230 | context math(context) 231 | snippet ddot "ddot" Ai 232 | \ddot{$1}$0 233 | endsnippet 234 | 235 | context math(context) 236 | snippet vec "vec" Ai 237 | \vec{$1}$0 238 | endsnippet 239 | 240 | context math(context) 241 | snippet tilde "tilde" Ai 242 | \tilde{$1}$0 243 | endsnippet 244 | 245 | context math(context) 246 | snippet Tilde "wide tilde" Ai 247 | \widetilde{$1}$0 248 | endsnippet 249 | 250 | context math(context) 251 | snippet und "und" Ai 252 | \underline{$1}$0 253 | endsnippet 254 | 255 | context math(context) 256 | snippet norm "norm" Ai 257 | \lVert $1 \rVert $0 258 | endsnippet 259 | 260 | context math(context) 261 | snippet abs "absolute value" Ai 262 | \lvert $1 \rvert $0 263 | endsnippet 264 | 265 | context math(context) 266 | snippet set "set" Ai 267 | \set{ $1 }$0 268 | endsnippet 269 | 270 | context math(context) 271 | snippet Set "large set" Ai 272 | \Set{ $1 }$0 273 | endsnippet 274 | 275 | 276 | ############################################################################## 277 | # Greek alphabet 278 | ############################################################################## 279 | context math(context) 280 | snippet @a "α" Ai 281 | \alpha 282 | endsnippet 283 | 284 | context math(context) 285 | snippet @b "β" Ai 286 | \beta 287 | endsnippet 288 | 289 | context math(context) 290 | snippet @g "γ" Ai 291 | \gamma 292 | endsnippet 293 | 294 | context math(context) 295 | snippet @G "Γ" Ai 296 | \Gamma 297 | endsnippet 298 | 299 | context math(context) 300 | snippet @d "δ" Ai 301 | \delta 302 | endsnippet 303 | 304 | context math(context) 305 | snippet @D "Δ" Ai 306 | \Delta 307 | endsnippet 308 | 309 | context math(context) 310 | snippet @e "ε" Ai 311 | \epsilon 312 | endsnippet 313 | 314 | context math(context) 315 | snippet @ve "variant of ε" Ai 316 | \varepsilon 317 | endsnippet 318 | 319 | context math(context) 320 | snippet @z "ζ" Ai 321 | \zeta 322 | endsnippet 323 | 324 | context math(context) 325 | snippet eta "η" Ai 326 | \eta 327 | endsnippet 328 | 329 | context math(context) 330 | snippet @t "θ" Ai 331 | \theta 332 | endsnippet 333 | 334 | context math(context) 335 | snippet @vt "variant of θ" Ai 336 | \vartheta 337 | endsnippet 338 | 339 | context math(context) 340 | snippet @T "Θ" Ai 341 | \Theta 342 | endsnippet 343 | 344 | context math(context) 345 | snippet @i "ι" Ai 346 | \iota 347 | endsnippet 348 | 349 | context math(context) 350 | snippet @k "κ" Ai 351 | \kappa 352 | endsnippet 353 | 354 | context math(context) 355 | snippet @l "λ" Ai 356 | \lambda 357 | endsnippet 358 | 359 | context math(context) 360 | snippet @L "Λ" Ai 361 | \Lambda 362 | endsnippet 363 | 364 | context math(context) 365 | snippet mu "μ" Ai 366 | \mu 367 | endsnippet 368 | 369 | context math(context) 370 | snippet nu "ν" Ai 371 | \nu 372 | endsnippet 373 | 374 | context math(context) 375 | snippet xi "ξ" Ai 376 | \xi 377 | endsnippet 378 | 379 | context math(context) 380 | snippet Xi "Ξ" Ai 381 | \Xi 382 | endsnippet 383 | 384 | context math(context) 385 | snippet pi "π" Ai 386 | \pi 387 | endsnippet 388 | 389 | context math(context) 390 | snippet Pi "Π" Ai 391 | \Pi 392 | endsnippet 393 | 394 | context math(context) 395 | snippet rho "ρ" Ai 396 | \rho 397 | endsnippet 398 | 399 | context math(context) 400 | snippet @vr "variant of ρ" Ai 401 | \varrho 402 | endsnippet 403 | 404 | context math(context) 405 | snippet @s "σ" Ai 406 | \sigma 407 | endsnippet 408 | 409 | context math(context) 410 | snippet @S "Σ" Ai 411 | \Sigma 412 | endsnippet 413 | 414 | context math(context) 415 | snippet @vs "variant of σ" Ai 416 | \varsigma 417 | endsnippet 418 | 419 | context math(context) 420 | snippet tau "τ" Ai 421 | \tau 422 | endsnippet 423 | 424 | context math(context) 425 | snippet @u "υ" Ai 426 | \upsilon 427 | endsnippet 428 | 429 | context math(context) 430 | snippet @U "Υ" Ai 431 | \Upsilon 432 | endsnippet 433 | 434 | context math(context) 435 | snippet phi "φ" Ai 436 | \phi 437 | endsnippet 438 | 439 | context math(context) 440 | snippet @vp "variant of φ" Ai 441 | \varphi 442 | endsnippet 443 | 444 | context math(context) 445 | snippet Phi "Φ" Ai 446 | \Phi 447 | endsnippet 448 | 449 | context math(context) 450 | snippet chi "χ" Ai 451 | \chi 452 | endsnippet 453 | 454 | context math(context) 455 | snippet psi "ψ" Ai 456 | \psi 457 | endsnippet 458 | 459 | context math(context) 460 | snippet Psi "Ψ" Ai 461 | \Psi 462 | endsnippet 463 | 464 | context math(context) 465 | snippet @o "ω" Ai 466 | \omega 467 | endsnippet 468 | 469 | context math(context) 470 | snippet @O "Ω" Ai 471 | \Omega 472 | endsnippet 473 | 474 | 475 | ############################################################################## 476 | # Symbols 477 | ############################################################################## 478 | context math(context) 479 | snippet ooo "infinity" Ai 480 | \infty 481 | endsnippet 482 | 483 | context math(context) 484 | snippet OO "emptyset" Ai 485 | \emptyset 486 | endsnippet 487 | 488 | context math(context) 489 | snippet sum "summation" Ai 490 | \sum 491 | endsnippet 492 | 493 | context math(context) 494 | snippet prod "production" Ai 495 | \prod 496 | endsnippet 497 | 498 | context math(context) 499 | snippet lim "limit" Ai 500 | \lim_{$1 \to $2}$0 501 | endsnippet 502 | 503 | context math(context) 504 | snippet ... "dots" Ai 505 | \dots 506 | endsnippet 507 | 508 | context math(context) 509 | snippet ..c "ellipsis for commas" Ai 510 | \dotsc 511 | endsnippet 512 | 513 | context math(context) 514 | snippet ..m "ellipsis for multiplications" Ai 515 | \dotsm 516 | endsnippet 517 | 518 | context math(context) 519 | snippet ..b "ellipsis for binary operations" Ai 520 | \dotsb 521 | endsnippet 522 | 523 | context math(context) 524 | snippet ..i "ellipsis for integrals" Ai 525 | \dotsi 526 | endsnippet 527 | 528 | context math(context) 529 | snippet ..o "other ellipsis" Ai 530 | \dotso 531 | endsnippet 532 | 533 | context math(context) 534 | snippet c.. "cdots" Ai 535 | \cdots 536 | endsnippet 537 | 538 | context math(context) 539 | snippet v.. "vdots" Ai 540 | \vdots 541 | endsnippet 542 | 543 | context math(context) 544 | snippet d.. "ddots" Ai 545 | \ddots 546 | endsnippet 547 | 548 | context math(context) 549 | snippet <-> "left rigth arrow" A 550 | \leftrightarrow 551 | endsnippet 552 | 553 | context math(context) 554 | snippet <--> "long left rigth arrow" A 555 | \longleftrightarrow 556 | endsnippet 557 | 558 | context math(context) 559 | snippet <=> "Left rigth arrow" A 560 | \Leftrightarrow 561 | endsnippet 562 | 563 | context math(context) 564 | snippet <==> "Long left rigth arrow" A 565 | \Longleftrightarrow 566 | endsnippet 567 | 568 | context math(context) 569 | snippet -> "to" A 570 | \to 571 | endsnippet 572 | 573 | context math(context) 574 | snippet to "to" A 575 | \to 576 | endsnippet 577 | 578 | context math(context) 579 | snippet `<-([^->])` "get" A 580 | \gets ``rv = m[1].trim()`` 581 | endsnippet 582 | 583 | context math(context) 584 | snippet |> "mapsto" A 585 | \mapsto 586 | endsnippet 587 | 588 | context math(context) 589 | snippet \\\ "setminus" A 590 | \setminus 591 | endsnippet 592 | 593 | context math(context) 594 | snippet || "middle" A 595 | \mid 596 | endsnippet 597 | 598 | context math(context) 599 | snippet `\\mid \|` "Parallel" A 600 | \parallel 601 | endsnippet 602 | 603 | context math(context) 604 | snippet and "logical and" A 605 | \cap 606 | endsnippet 607 | 608 | context math(context) 609 | snippet orr "logical or" A 610 | \cup 611 | endsnippet 612 | 613 | context math(context) 614 | snippet wed "wedge symbol" A 615 | \wedge 616 | endsnippet 617 | 618 | context math(context) 619 | snippet Wed "wedge operator" Ai 620 | \bigwedge 621 | endsnippet 622 | 623 | context math(context) 624 | snippet vel "descending wedge symbol" A 625 | \vee 626 | endsnippet 627 | 628 | context math(context) 629 | snippet Vel "descending wedge operator" Ai 630 | \bigvee 631 | endsnippet 632 | 633 | context math(context) 634 | snippet cap "cap" A 635 | \cap 636 | endsnippet 637 | 638 | context math(context) 639 | snippet Cap "Big cap" Ai 640 | \bigcap 641 | endsnippet 642 | 643 | context math(context) 644 | snippet cup "cup" A 645 | \cup 646 | endsnippet 647 | 648 | context math(context) 649 | snippet Cup "Big cup" Ai 650 | \bigcup 651 | endsnippet 652 | 653 | context math(context) 654 | snippet inn "set in" A 655 | \in 656 | endsnippet 657 | 658 | context math(context) 659 | snippet subset "subset" A 660 | \subset 661 | endsnippet 662 | 663 | context math(context) 664 | snippet `\\subset eq` "subseteq" A 665 | \subseteq 666 | endsnippet 667 | 668 | context math(context) 669 | snippet => "implies" A 670 | \implies 671 | endsnippet 672 | 673 | context math(context) 674 | snippet =< "impliedby" A 675 | \impliedby 676 | endsnippet 677 | 678 | context math(context) 679 | snippet iff "if and only if" A 680 | \iff 681 | endsnippet 682 | 683 | context math(context) 684 | snippet exists "exists" Ai 685 | \exists 686 | endsnippet 687 | 688 | context math(context) 689 | snippet `e\\xi sts` "exists" Ai 690 | \exists 691 | endsnippet 692 | 693 | context math(context) 694 | snippet forall "for all" Ai 695 | \forall 696 | endsnippet 697 | 698 | context math(context) 699 | snippet s.t. "such that or subjected to" A 700 | \text{s.t.} 701 | endsnippet 702 | 703 | context math(context) 704 | snippet === "equiv" A 705 | \equiv 706 | endsnippet 707 | 708 | context math(context) 709 | snippet := "colon eq" A 710 | \coloneq 711 | endsnippet 712 | 713 | context math(context) 714 | snippet =: "eq colon" A 715 | \eqcolon 716 | endsnippet 717 | 718 | context math(context) 719 | snippet Sq "square" Ai 720 | \square 721 | endsnippet 722 | 723 | context math(context) 724 | snippet != "not eq" A 725 | \neq 726 | endsnippet 727 | 728 | context math(context) 729 | snippet `>=(.)` "greater than or equal to" A 730 | \geq ``rv = m[1].trim()`` 731 | endsnippet 732 | 733 | context math(context) 734 | snippet `<=([^=])` "less than or equal to" A 735 | \leq ``rv = m[1].trim()`` 736 | endsnippet 737 | 738 | context math(context) 739 | snippet >> "much greater than" A 740 | \gg 741 | endsnippet 742 | 743 | context math(context) 744 | snippet << "much less than" A 745 | \ll 746 | endsnippet 747 | 748 | context math(context) 749 | snippet ~~ "similar" A 750 | \sim 751 | endsnippet 752 | 753 | context math(context) 754 | snippet ~= "similar" A 755 | \simeq 756 | endsnippet 757 | 758 | context math(context) 759 | snippet \sim~ "approx" A 760 | \approx 761 | endsnippet 762 | 763 | context math(context) 764 | snippet prop "propotional to" A 765 | \propto 766 | endsnippet 767 | 768 | context math(context) 769 | snippet nabl "nabla" Ai 770 | \nabla 771 | endsnippet 772 | 773 | context math(context) 774 | snippet del "nabla" i 775 | \nabla 776 | endsnippet 777 | 778 | context math(context) 779 | snippet div "divergence" Ai 780 | \div 781 | endsnippet 782 | 783 | context math(context) 784 | snippet rot "rotation" Ai 785 | \rot 786 | endsnippet 787 | 788 | context math(context) 789 | snippet grad "gradient" Ai 790 | \grad 791 | endsnippet 792 | 793 | context math(context) 794 | snippet xx "times" A 795 | \times 796 | endsnippet 797 | 798 | context math(context) 799 | snippet ** "cdot" A 800 | \cdot 801 | endsnippet 802 | 803 | context math(context) 804 | snippet cc "cdot" A 805 | \cdot 806 | endsnippet 807 | 808 | context math(context) 809 | snippet para "parallel" A 810 | \parallel 811 | endsnippet 812 | 813 | context math(context) 814 | snippet xnn "x sub n" Ai 815 | x_{n} 816 | endsnippet 817 | 818 | context math(context) 819 | snippet xii "x sub i" Ai 820 | x_{i} 821 | endsnippet 822 | 823 | context math(context) 824 | snippet `\\xi i` "x sub i" Ai 825 | x_{i} 826 | endsnippet 827 | 828 | context math(context) 829 | snippet xjj "x sub j" Ai 830 | x_{j} 831 | endsnippet 832 | 833 | context math(context) 834 | snippet xp1 "x sub n + 1" Ai 835 | x_{n+1} 836 | endsnippet 837 | 838 | context math(context) 839 | snippet ynn "y sub n" Ai 840 | y_{n} 841 | endsnippet 842 | 843 | context math(context) 844 | snippet yii "y sub i" Ai 845 | y_{i} 846 | endsnippet 847 | 848 | context math(context) 849 | snippet yjj "y sub j" Ai 850 | y_{j} 851 | endsnippet 852 | 853 | context math(context) 854 | snippet mcal "mathcal" Ai 855 | \mathcal{$1}$0 856 | endsnippet 857 | 858 | context math(context) 859 | snippet mbb "mathbb" Ai 860 | \mathbb{$1}$0 861 | endsnippet 862 | 863 | context math(context) 864 | snippet ell "ell" Ai 865 | \ell 866 | endsnippet 867 | 868 | context math(context) 869 | snippet lll "ell" Ai 870 | \ell 871 | endsnippet 872 | 873 | context math(context) 874 | snippet LL "Calligraphy L" Ai 875 | \mathcal{L} 876 | endsnippet 877 | 878 | context math(context) 879 | snippet HH "Calligraphy H" Ai 880 | \mathcal{H} 881 | endsnippet 882 | 883 | context math(context) 884 | snippet CC "Complex field" Ai 885 | \mathbb{C} 886 | endsnippet 887 | 888 | context math(context) 889 | snippet RR "Real field" Ai 890 | \mathbb{R} 891 | endsnippet 892 | 893 | context math(context) 894 | snippet ZZ "Integer group" Ai 895 | \mathbb{Z} 896 | endsnippet 897 | 898 | context math(context) 899 | snippet NN "Natural number group" Ai 900 | \mathbb{N} 901 | endsnippet 902 | 903 | context math(context) 904 | snippet II "Unit" Ai 905 | \mathbb{1} 906 | endsnippet 907 | 908 | context math(context) 909 | snippet \mathbb{1}I "Unit (alt)" Ai 910 | \hat{\mathbb{1}} 911 | endsnippet 912 | 913 | context math(context) 914 | snippet AA "Calligraphy A" Ai 915 | \mathcal{A} 916 | endsnippet 917 | 918 | context math(context) 919 | snippet BB "bold B" Ai 920 | \mathbf{B} 921 | endsnippet 922 | 923 | context math(context) 924 | snippet EE "bold E" Ai 925 | \mathbf{E} 926 | endsnippet 927 | 928 | context math(context) 929 | snippet ii "imaginary unit" Ai 930 | \mathrm{i} 931 | endsnippet 932 | 933 | 934 | ############################################################################## 935 | # Unit vectors 936 | ############################################################################## 937 | context math(context) 938 | snippet :i "i-th unit vector" Ai 939 | \mathbf{i} 940 | endsnippet 941 | 942 | context math(context) 943 | snippet :j "j-th unit vector" Ai 944 | \mathbf{j} 945 | endsnippet 946 | 947 | context math(context) 948 | snippet :k "k-th unit vector" Ai 949 | \mathbf{k} 950 | endsnippet 951 | 952 | context math(context) 953 | snippet :x "x unit" Ai 954 | \hat{\mathbf{x}} 955 | endsnippet 956 | 957 | context math(context) 958 | snippet :y "y unit" Ai 959 | \hat{\mathbf{y}} 960 | endsnippet 961 | 962 | context math(context) 963 | snippet :z "z unit" Ai 964 | \hat{\mathbf{z}} 965 | endsnippet 966 | 967 | context math(context) 968 | snippet `\:e(.)` "e unit" Ai 969 | \mathbf{e}_{``rv=m[1]``} 970 | endsnippet 971 | 972 | 973 | ############################################################################## 974 | # Derivatives 975 | ############################################################################## 976 | context math(context) 977 | snippet par "partial derivative" i 978 | \frac{\partial $1}{\partial $2}$0 979 | endsnippet 980 | 981 | context math(context) 982 | snippet pa2 "second partial derivative" Ai 983 | \frac{\partial^2 $1}{\partial $2^2}$0 984 | endsnippet 985 | 986 | context math(context) 987 | snippet pa3 "third partial derivative" Ai 988 | \frac{\partial^3 $1}{\partial $2^3}$0 989 | endsnippet 990 | 991 | context math(context) 992 | snippet `pa([a-zA-Z])([a-zA-Z])` "regex partial derivative" i 993 | \frac{\partial ``rv = m[1]``}{\partial ``rv = m[2]``} 994 | endsnippet 995 | 996 | context math(context) 997 | snippet `pa([a-zA-Z])([a-zA-Z])([a-zA-Z])` "regex partial derivative two vars" i 998 | \frac{\partial^2 ``rv = m[1]``}{\partial ``rv = m[2]`` \partial ``rv = m[3]``} 999 | endsnippet 1000 | 1001 | context math(context) 1002 | snippet `pa([a-zA-Z])([a-zA-Z])2` "regex second partial derivative" Ai 1003 | \frac{\partial^2 ``rv = m[1]``}{\partial ``rv = m[2]``^2} 1004 | endsnippet 1005 | 1006 | context math(context) 1007 | snippet `d([a-zA-Z])d([a-zA-Z])` "regex derivative" i 1008 | \frac{d ``rv = m[1]``}{d ``rv = m[2]``} 1009 | endsnippet 1010 | 1011 | context math(context) 1012 | snippet `d([a-zA-Z])d([a-zA-Z])2` "regex second derivative" Ai 1013 | \frac{d^2 ``rv = m[1]``}{d ``rv = m[2]``^2} 1014 | endsnippet 1015 | 1016 | context math(context) 1017 | snippet ddt "time differential operator" Ai 1018 | \frac{d}{dt} 1019 | endsnippet 1020 | 1021 | context math(context) 1022 | snippet ddx "differential operator" Ai 1023 | \frac{d}{dx} 1024 | endsnippet 1025 | 1026 | context math(context) 1027 | snippet `del([A-Za-z])` "Abbreviated partial derivative" i 1028 | \partial_{``rv = m[1]``} 1029 | endsnippet 1030 | 1031 | context math(context) 1032 | snippet `Del([A-Za-z])` "Abbreviated partial derivative operator" i 1033 | D_{``rv = m[1]``} 1034 | endsnippet 1035 | 1036 | 1037 | ############################################################################## 1038 | # Integrals 1039 | ############################################################################## 1040 | context math(context) 1041 | snippet int "integral" A 1042 | \int d$1 \, $0 1043 | endsnippet 1044 | 1045 | context math(context) 1046 | snippet dint "definite integral" A 1047 | \int_{$1}^{$2} d$3 \, $0 1048 | endsnippet 1049 | 1050 | context math(context) 1051 | snippet oinf "half improper integral" A 1052 | \int_{0}^{\infty} d$1 \, $0 1053 | endsnippet 1054 | 1055 | context math(context) 1056 | snippet infi "improper integral" A 1057 | \int_{-\infty}^{\infty} d$1 \, $0 1058 | endsnippet 1059 | 1060 | context math(context) 1061 | snippet oint "closed loop integral" A 1062 | \oint 1063 | endsnippet 1064 | 1065 | context math(context) 1066 | snippet `\\mathrm{i}nt` "2-fold integral" A 1067 | \iint 1068 | endsnippet 1069 | 1070 | context math(context) 1071 | snippet `\\mathrm{i}int` "3-fold integral" A 1072 | \iiint 1073 | endsnippet 1074 | 1075 | context math(context) 1076 | snippet i.int "indefinite integral" A 1077 | \idotsint d$1 \, $0 1078 | endsnippet 1079 | 1080 | 1081 | ############################################################################## 1082 | # Physics 1083 | ############################################################################## 1084 | context math(context) 1085 | snippet kbt "temperature multiplied by the boltzmann constant" Ai 1086 | k_{\text{B}}T 1087 | endsnippet 1088 | 1089 | context math(context) 1090 | snippet hbar "hbar" Ai 1091 | \hbar 1092 | endsnippet 1093 | 1094 | context math(context) 1095 | snippet `([ ]*)dag` "dagger" Ai 1096 | ^\dagger 1097 | endsnippet 1098 | 1099 | context math(context) 1100 | snippet o+ "direct sum" A 1101 | \oplus 1102 | endsnippet 1103 | 1104 | context math(context) 1105 | snippet O+ "big direct sum" Ai 1106 | \bigoplus 1107 | endsnippet 1108 | 1109 | context math(context) 1110 | snippet ox "direct product" A 1111 | \otimes 1112 | endsnippet 1113 | 1114 | context math(context) 1115 | snippet otimes "direct product (alt)" A 1116 | \otimes 1117 | endsnippet 1118 | 1119 | context math(context) 1120 | snippet Ox "big direct product" Ai 1121 | \bigotimes 1122 | endsnippet 1123 | 1124 | context math(context) 1125 | snippet bra "bra vector" Ai 1126 | \bra{$1}$0 1127 | endsnippet 1128 | 1129 | context math(context) 1130 | snippet ket "ket vector" Ai 1131 | \ket{$1}$0 1132 | endsnippet 1133 | 1134 | context math(context) 1135 | snippet brk "braket" Ai 1136 | \braket{$1}$0 1137 | endsnippet 1138 | 1139 | context math(context) 1140 | snippet `\\bra{([^|]+)\|` "bra to braket" Ai 1141 | \braket{``rv = m[1]`` | $0 1142 | endsnippet 1143 | 1144 | context math(context) 1145 | snippet outp "outer product" Ai 1146 | \ket{$1}\!\bra{$1}$0 1147 | endsnippet 1148 | 1149 | context math(context) 1150 | snippet Bra "large bra vector" Ai 1151 | \Bra{$1}$0 1152 | endsnippet 1153 | 1154 | context math(context) 1155 | snippet Ket "large ket vector" Ai 1156 | \Ket{$1}$0 1157 | endsnippet 1158 | 1159 | context math(context) 1160 | snippet Brk "large braket" Ai 1161 | \Braket{$1}$0 1162 | endsnippet 1163 | 1164 | context math(context) 1165 | snippet `\\Bra{([^|]+)\|` "large bra to large braket" Ai 1166 | \Braket{``rv = m[1]`` | $0 1167 | endsnippet 1168 | 1169 | context math(context) 1170 | snippet Outp "large outer product" Ai 1171 | \Ket{$1}\!\Bra{$1}$0 1172 | endsnippet 1173 | 1174 | # context math(context) 1175 | # snippet Ope "large operator" A 1176 | # \Ket{$1\vphantom{$2}}\!\Bra{$2\vphantom{$1}}$0 1177 | # endsnippet 1178 | 1179 | 1180 | ############################################################################## 1181 | # Environments 1182 | ############################################################################## 1183 | context math(context) 1184 | snippet beg "environment" A 1185 | \begin{$1} 1186 | $0 1187 | \end{$1} 1188 | endsnippet 1189 | 1190 | context math(context) 1191 | snippet pmat "parentheses matrix" 1192 | \begin{pmatrix} 1193 | $1 1194 | \end{pmatrix}$0 1195 | endsnippet 1196 | 1197 | context math(context) 1198 | snippet bmat "bracket matrix" 1199 | \begin{bmatrix} 1200 | $1 1201 | \end{bmatrix}$0 1202 | endsnippet 1203 | 1204 | context math(context) 1205 | snippet Bmat "brace matrix" 1206 | \begin{Bmatrix} 1207 | $1 1208 | \end{Bmatrix}$0 1209 | endsnippet 1210 | 1211 | context math(context) 1212 | snippet vmat "vartical line matrix" 1213 | \begin{vmatrix} 1214 | $1 1215 | \end{vmatrix}$0 1216 | endsnippet 1217 | 1218 | context math(context) 1219 | snippet Vmat "double vartical line matrix" 1220 | \begin{Vmatrix} 1221 | $1 1222 | \end{Vmatrix}$0 1223 | endsnippet 1224 | 1225 | context math(context) 1226 | snippet case "cases" 1227 | \begin{cases} 1228 | $1 1229 | \end{cases}$0 1230 | endsnippet 1231 | 1232 | context math(context) 1233 | snippet arr "array" 1234 | \begin{array}{|c|} 1235 | $1 1236 | \end{array}$0 1237 | endsnippet 1238 | 1239 | context math(context) 1240 | snippet mat "matrix" 1241 | \begin{matrix} 1242 | $1 1243 | \end{matrix}$0 1244 | endsnippet 1245 | 1246 | 1247 | ############################################################################## 1248 | # Brackets 1249 | ############################################################################## 1250 | context math(context) 1251 | snippet avg "average" Ai 1252 | \langle $1 \rangle $0 1253 | endsnippet 1254 | 1255 | context math(context) 1256 | snippet mod "mod" Ai 1257 | | $1 |$0 1258 | endsnippet 1259 | 1260 | context math(context) 1261 | snippet lr() "large parentheses " Ai 1262 | \left( $0 \right) 1263 | endsnippet 1264 | 1265 | context math(context) 1266 | snippet lr| "large bars" Ai 1267 | \left| $0 \right| 1268 | endsnippet 1269 | 1270 | context math(context) 1271 | snippet lr{} "large braces" Ai 1272 | \left\{ $0 \right\} 1273 | endsnippet 1274 | 1275 | context math(context) 1276 | snippet lr[] "large brackets" Ai 1277 | \left[ $0 \right] 1278 | endsnippet 1279 | 1280 | context math(context) 1281 | snippet lr< "large angle brackets" Ai 1282 | \left< $0 \right> 1283 | endsnippet 1284 | 1285 | 1286 | ############################################################################## 1287 | # Fraction 1288 | ############################################################################## 1289 | context math(context) 1290 | snippet // "Fraction simple" Ai 1291 | \frac{$1}{$2}$0 1292 | endsnippet 1293 | 1294 | context math(context) 1295 | snippet `((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/` "Fraction no ()" Ai 1296 | \frac{``rv = m[1]``}{$1}$0 1297 | endsnippet 1298 | 1299 | context math(context) 1300 | snippet `^.*\)/` "() Fraction" Ai 1301 | `` 1302 | let stripped = m[0].substring(0, m[0].length - 1); 1303 | let depth = 0; 1304 | let i = stripped.length - 1; 1305 | while (i >= 0) { 1306 | if (stripped[i] == ')') depth += 1; 1307 | if (stripped[i] == '(') depth -= 1 1308 | if (depth == 0) break; 1309 | i -= 1 1310 | } 1311 | rv = `${stripped.substring(0, i)}\\frac{${stripped.substring(i + 1, stripped.length - 1)}}`; 1312 | ``{$1}$0 1313 | endsnippet 1314 | 1315 | 1316 | ############################################################################## 1317 | # Utilities 1318 | ############################################################################## 1319 | context math(context) 1320 | snippet ;a "Insert @ symbol" Ai 1321 | @ 1322 | endsnippet 1323 | 1324 | context math(context) 1325 | snippet ;f "Insert & symbol to separate rows" Ai 1326 | & 1327 | endsnippet 1328 | --------------------------------------------------------------------------------