The pluginās main feature isĀ snippets, which help you write LaTeX quicker through shortcuts and text expansion! For example, type
- āsqxā instead of ā\sqrt{x}ā
- āa/bā instead of ā\frac{a}{b}ā
- āpar x y ā instead of ā\frac{\partial x}{\partial y}ā
SeeĀ Gilles Castelās writeupĀ for more information.
The plugin comes with aĀ set of default snippets, loosely based onĀ Gilles Castelās. You can modify them, remove them, and write your own.
Usage
To get started, type ādmā to enter display math mode. Try typing the following:
-
āxsrā ā āx^{2}ā.
-
āx/yĀ Tabā ā ā\frac{x}{y}ā.
-
āsin @tā ā ā\sin \thetaā.
Have a look at theĀ cheatsheetĀ for a list of commonly used default snippets.
Once these feel familiar, you can check out theĀ default snippetsĀ for more commands. e.g.
-
āparĀ TabĀ fĀ TabĀ xĀ Tabā ā ā\frac{\partial f}{\partial x}ā.
-
ādintĀ TabĀ 2piĀ TabĀ sin @tĀ TabĀ @tĀ Tabā ā ā\int_{0}^{2\pi} \sin \theta , d\thetaā.
You can also add your own snippets!Ā See here for more info on writing snippets. You canĀ view snippets written by others and share your own snippets here.
Features
Auto-fraction
Lets you type ā1/xā instead of ā\frac{1}{x}ā.
For example, it makes the following expansions:
x/
Ā āĀ\frac{x}{}
(a + b(c + d))/
Ā āĀ\frac{a + b(c + d)}{}
and moves the cursor inside the brackets.
Once done typing the denominator, pressĀ TabĀ to exit the fraction.
Matrix shortcuts
While inside a matrix, array, align, or cases environment,
- PressingĀ TabĀ will insert the ā&ā symbol
- PressingĀ EnterĀ will insert ā\ā and move to a new line
- PressingĀ Shift + EnterĀ will move to the end of the next line (can be used to exit the matrix)
Conceal
This feature must be enabled in settings!
Make your equations more readable by hiding LaTeX code, instead rendering it in a pretty format.
For example, ā\dot{x}^{2} + \dot{y}^{2}ā will be displayed as āįŗĀ² + įŗĀ²ā.
To reveal the LaTeX code, move the cursor over it.
Ā
Tabout
- PressingĀ TabĀ while the cursor is at the end of an equation will move the cursor outside the $ symbols.
- Otherwise, pressingĀ TabĀ will advance the cursor to the next closing bracket: ), ], }, >, or |.
Preview inline math
When the cursor is inside inline math, a popup window showing the rendered math will be displayed.
Ā
Color & highlight matching brackets
- Matching brackets are rendered in the same color, to help with readability.
- When the cursor is adjacent to a bracket, that bracket and its pair will be highlighted.
- When the cursor is inside brackets, the enclosing brackets will be highlighted.
Visual snippets
Sometimes you want to annotate math, or cancel or cross out terms. Selecting some math with the cursor and typing
- āUā will surround it with ā\underbraceā.
- āOā will surround it with ā\overbraceā.
- āCā will surround it with ā\cancelā.
- āKā will surround it with ā\canceltoā.
- āBā will surround it with ā\undersetā.
Auto-enlarge brackets
When a snippet containing ā\sumā, ā\intā or ā\fracā is triggered, any enclosing brackets will be enlarged with ā\leftā and ā\rightā.
Editor commands
- Box current equation ā surround the equation the cursor is currently in with a box.
- Select current equation ā select the equation the cursor is currently in.
Snippets
Snippets are formatted as follows:
{
trigger: string | RegExp,
replacement: string,
options: string,
priority?: number,
description?: string,
flags?: string,
}
trigger
Ā : The text that triggers this snippet.- Triggers can also be regular expressions.Ā See here for more info.
replacement
Ā : The text to replace theĀtrigger
Ā with.- Replacements can also be JavaScript functions.Ā See here for more info.
options
Ā : See below.priority
Ā (optional): This snippetās priority. Snippets with higher priority are run first. Can be negative. Defaults to 0.description
Ā (optional): A description for this snippet.flags
Ā (optional): Flags for regex snippets.
Options
t
Ā : Text mode. Only run this snippet outside mathm
Ā : Math mode. Only run this snippet inside math. Shorthand for bothĀM
Ā andĀn
M
Ā : Block math mode. Only run this snippet inside aĀ$$ ... $$
Ā blockn
Ā : Inline math mode. Only run this snippet inside aĀ$ ... $
Ā blockA
Ā : Auto. Expand this snippet as soon as the trigger is typed. If omitted, theĀ TabĀ key must be pressed to expand the snippetr
Ā :Ā Regex. TheĀtrigger
Ā will be treated as a regular expressionv
Ā :Ā Visual. Only run this snippet on a selection. The trigger should be a single characterw
Ā : Word boundary. Only run this snippet when the trigger is preceded (and followed by) a word delimiter, such asĀ.
,Ā,
, orĀ-
.c
Ā : Code mode. Only run this snippet inside aĀ``` ... ```
Ā block
InsertĀ tabstopsĀ for the cursor to jump to by writing ā1ā, etc. in theĀ replacement
.
For more details on writing snippets, includingĀ regexĀ snippets andĀ functionĀ snippets,Ā see theĀ documentationĀ here. You canĀ view snippets written by others and share your own snippets here.
Warning
Snippet files are interpreted as JavaScript and can execute arbitrary code. Always be careful with snippets shared from others to avoid running malicious code.
Cheatsheet
Trigger | Replacement |
---|---|
mk | $ $ |
dm | $$ $$ |
sr | ^{2} |
cb | ^{3} |
rd | ^{ } |
_ | _{ } |
sq | \sqrt{ } |
x/y Tab | \frac{x}{y} |
// | \frac{ }{ } |
te Tab | \text{ } |
x1 | x_{1} |
x,. | \mathbf{x} |
x., | \mathbf{x} |
xdot | \dot{x} |
xhat | \hat{x} |
xbar | \bar{x} |
xvec | \vec{x} |
xtilde | \tilde{x} |
xund | \underline{x} |
ee | e^{ } |
When running a snippet thatĀ moves the cursor inside brackets {}, pressĀ TabĀ to exit the brackets.
Greek letters
Trigger | Replacement | Trigger | Replacement |
---|---|---|---|
@a | \alpha | eta | \eta |
@b | \beta | mu | \mu |
@g | \gamma | nu | \nu |
@G | \Gamma | xi | \xi |
@d | \delta | Xi | \Xi |
@D | \Delta | pi | \pi |
@e | \epsilon | Pi | \Pi |
:e | \varepsilon | rho | \rho |
@z | \zeta | tau | \tau |
@t | \theta | phi | \phi |
@T | \Theta | Phi | \Phi |
@k | \kappa | chi | \chi |
@l | \lambda | psi | \psi |
@L | \Lambda | Psi | \Psi |
@s | \sigma | ||
@S | \Sigma | ||
@o | \omega | ||
ome | \omega |
For greek letters with short names (2-3 characters), just type their name, e.g. āpiā ā ā\piā
[
// Math mode
{trigger: "mk", replacement: "$$0$", options: "tA"},
{trigger: "dm", replacement: "$$\n$0\n$$", options: "tAw"},
{trigger: "beg", replacement: "\\begin{$0}\n$1\n\\end{$0}", options: "mA"},
// Dashes
// {trigger: "--", replacement: "ā", options: "tA"},
// {trigger: "ā-", replacement: "ā", options: "tA"},
// {trigger: "ā-", replacement: "---", options: "tA"},
// Greek letters
{trigger: "@a", replacement: "\\alpha", options: "mA"},
{trigger: "@A", replacement: "\\alpha", options: "mA"},
{trigger: "@b", replacement: "\\beta", options: "mA"},
{trigger: "@B", replacement: "\\beta", options: "mA"},
{trigger: "@c", replacement: "\\chi", options: "mA"},
{trigger: "@C", replacement: "\\chi", options: "mA"},
{trigger: "@g", replacement: "\\gamma", options: "mA"},
{trigger: "@G", replacement: "\\Gamma", options: "mA"},
{trigger: "@d", replacement: "\\delta", options: "mA"},
{trigger: "@D", replacement: "\\Delta", options: "mA"},
{trigger: "@e", replacement: "\\epsilon", options: "mA"},
{trigger: "@E", replacement: "\\epsilon", options: "mA"},
{trigger: ":e", replacement: "\\varepsilon", options: "mA"},
{trigger: ":E", replacement: "\\varepsilon", options: "mA"},
{trigger: "@z", replacement: "\\zeta", options: "mA"},
{trigger: "@Z", replacement: "\\zeta", options: "mA"},
{trigger: "@t", replacement: "\\theta", options: "mA"},
{trigger: "@T", replacement: "\\Theta", options: "mA"},
{trigger: "@k", replacement: "\\kappa", options: "mA"},
{trigger: "@K", replacement: "\\kappa", options: "mA"},
{trigger: "@l", replacement: "\\lambda", options: "mA"},
{trigger: "@L", replacement: "\\Lambda", options: "mA"},
{trigger: "@m", replacement: "\\mu", options: "mA"},
{trigger: "@M", replacement: "\\mu", options: "mA"},
{trigger: "@r", replacement: "\\rho", options: "mA"},
{trigger: "@R", replacement: "\\rho", options: "mA"},
{trigger: "@s", replacement: "\\sigma", options: "mA"},
{trigger: "@S", replacement: "\\Sigma", options: "mA"},
{trigger: "ome", replacement: "\\omega", options: "mA"},
{trigger: "@o", replacement: "\\omega", options: "mA"},
{trigger: "@O", replacement: "\\Omega", options: "mA"},
{trigger: "@u", replacement: "\\upsilon", options: "mA"},
{trigger: "@U", replacement: "\\Upsilon", options: "mA"},
{trigger: "([^\\\\])(${GREEK}|${SYMBOL})", replacement: "[[0]]\\[[1]]", options: "rmA", description: "Add backslash before greek letters and symbols"},
// Insert space after greek letters and symbols, etc
{trigger: "\\\\(${GREEK}|${SYMBOL}|${SHORT_SYMBOL})([A-Za-z])", replacement: "\\[[0]] [[1]]", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) sr", replacement: "\\[[0]]^{2}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) cb", replacement: "\\[[0]]^{3}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) rd", replacement: "\\[[0]]^{$0}$1", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) hat", replacement: "\\hat{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) dot", replacement: "\\dot{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) bar", replacement: "\\bar{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) vec", replacement: "\\vec{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) tilde", replacement: "\\tilde{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK}|${SYMBOL}) und", replacement: "\\underline{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK}),\\.", replacement: "\\boldsymbol{\\[[0]]}", options: "rmA"},
{trigger: "\\\\(${GREEK})\\.,", replacement: "\\boldsymbol{\\[[0]]}", options: "rmA"},
// Operations
{trigger: "te", replacement: "\\text{$0}", options: "m"},
{trigger: "text", replacement: "\\text{$0}", options: "mA"},
{trigger: "bf", replacement: "\\mathbf{$0}", options: "mA"},
{trigger: "sr", replacement: "^{2}", options: "mA"},
{trigger: "cb", replacement: "^{3}", options: "mA"},
{trigger: "rd", replacement: "^{$0}$1", options: "mA"},
{trigger: "_", replacement: "_{$0}$1", options: "mA"},
{trigger: "sts", replacement: "_\\text{$0}", options: "rmA"},
{trigger: "sq", replacement: "\\sqrt{ $0 }$1", options: "mA"},
{trigger: "//", replacement: "\\frac{$0}{$1}$2", options: "mA"},
{trigger: "ee", replacement: "e^{ $0 }$1", options: "mA"},
{trigger: "rm", replacement: "\\mathrm{$0}$1", options: "mA"},
{trigger: "conj", replacement: "^{*}", options: "mA"},
{trigger: "trace", replacement: "\\mathrm{Tr}", options: "mA"},
{trigger: "det", replacement: "\\det", options: "mA"},
{trigger: "re", replacement: "\\mathrm{Re}", options: "mA"},
{trigger: "im", replacement: "\\mathrm{Im}", options: "mA"},
{trigger: "([a-zA-Z]),\\.", replacement: "\\mathbf{[[0]]}", options: "rmA"},
{trigger: "([a-zA-Z])\\.,", replacement: "\\mathbf{[[0]]}", options: "rmA"},
{trigger: "([A-Za-z])(\\d)", replacement: "[[0]]_{[[1]]}", options: "rmA", description: "Auto letter subscript", priority: -1},
{trigger: "([A-Za-z])_(\\d\\d)", replacement: "[[0]]_{[[1]]}", options: "rmA"},
{trigger: "\\hat{([A-Za-z])}(\\d)", replacement: "hat{[[0]]}_{[[1]]}", options: "rmA"},
{trigger: "\\\\mathbf{([A-Za-z])}(\\d)", replacement: "\\mathbf{[[0]]}_{[[1]]}", options: "rmA"},
{trigger: "\\\\vec{([A-Za-z])}(\\d)", replacement: "\\vec{[[0]]}_{[[1]]}", options: "rmA"},
{trigger: "([a-zA-Z])bar", replacement: "\\bar{[[0]]}", options: "rmA"},
{trigger: "([a-zA-Z])hat", replacement: "\\hat{[[0]]}", options: "rmA"},
{trigger: "([a-zA-Z])ddot", replacement: "\\ddot{[[0]]}", options: "rmA", priority: 3},
{trigger: "([a-zA-Z])dot", replacement: "\\dot{[[0]]}", options: "rmA", priority: 1},
{trigger: "([a-zA-Z])vec", replacement: "\\vec{[[0]]}", options: "rmA"},
{trigger: "([a-zA-Z])tilde", replacement: "\\tilde{[[0]]}", options: "rmA"},
{trigger: "([a-zA-Z])und", replacement: "\\underline{[[0]]}", options: "rmA"},
{trigger: "bar", replacement: "\\bar{$0}$1", options: "mA"},
{trigger: "hat", replacement: "\\hat{$0}$1", options: "mA"},
{trigger: "dot", replacement: "\\dot{$0}$1", options: "mA"},
{trigger: "ddot", replacement: "\\ddot{$0}$1", options: "mA", priority: 2},
{trigger: "cdot", replacement: "\\cdot", options: "mA", priority: 2},
{trigger: "vec", replacement: "\\vec{$0}$1", options: "mA"},
{trigger: "tilde", replacement: "\\tilde{$0}$1", options: "mA"},
{trigger: "und", replacement: "\\underline{$0}$1", options: "mA"},
{trigger: "([^\\\\])(arcsin|arccos|arctan|arccot|arccsc|arcsec|sin|cos|tan|cot|csc|sec)", replacement: "[[0]]\\[[1]]", options: "rmA"},
{trigger: "\\\\(arcsin|arccos|arctan|arccot|arccsc|arcsec|sin|cos|tan|cot|csc|sec)([A-Za-gi-z])", replacement: "\\[[0]] [[1]]", options: "rmA"}, // Insert space after trig funcs. Skips letter "h" to allow sinh, cosh, etc.
{trigger: "\\\\(arcsinh|arccosh|arctanh|arccoth|arcsch|arcsech|sinh|cosh|tanh|coth|csch|sech)([A-Za-z])", replacement: "\\[[0]] [[1]]", options: "rmA"}, // Insert space after trig funcs
{trigger: "\\\\(neq|geq|leq|gg|ll|sim)([0-9]+)", replacement: "\\[[0]] [[1]]", options: "rmA"}, // Insert space after inequality symbols
// Visual operations
{trigger: "U", replacement: "\\underbrace{ ${VISUAL} }_{ $0 }", options: "mA"},
{trigger: "O", replacement: "\\overbrace{ ${VISUAL} }^{ $0 }", options: "mA"},
{trigger: "B", replacement: "\\underset{ $0 }{ ${VISUAL} }", options: "mA"},
{trigger: "C", replacement: "\\cancel{ ${VISUAL} }", options: "mA"},
{trigger: "K", replacement: "\\cancelto{ $0 }{ ${VISUAL} }", options: "mA"},
{trigger: "S", replacement: "\\sqrt{ ${VISUAL} }", options: "mA"},
// Symbols
{trigger: "ooo", replacement: "\\infty", options: "mA"},
{trigger: "sum", replacement: "\\sum", options: "mA"},
{trigger: "prod", replacement: "\\prod", options: "mA"},
{trigger: "lim", replacement: "\\lim_{ ${0:n} \\to ${1:\\infty} } $2", options: "mA"},
{trigger: "([^\\\\])pm", replacement: "[[0]]\\pm", options: "rm"},
{trigger: "([^\\\\])mp", replacement: "[[0]]\\mp", options: "rm"},
{trigger: "+-", replacement: "\\pm", options: "mA"},
{trigger: "-+", replacement: "\\mp", options: "mA"},
{trigger: "...", replacement: "\\dots", options: "mA"},
{trigger: "<->", replacement: "\\leftrightarrow ", options: "mA"},
{trigger: "->", replacement: "\\to", options: "mA"},
{trigger: "!>", replacement: "\\mapsto", options: "mA"},
{trigger: "invs", replacement: "^{-1}", options: "mA"},
{trigger: "\\\\\\", replacement: "\\setminus", options: "mA"},
{trigger: "||", replacement: "\\mid", options: "mA"},
{trigger: "and", replacement: "\\cap", options: "mA"},
{trigger: "orr", replacement: "\\cup", options: "mA"},
{trigger: "inn", replacement: "\\in", options: "mA"},
{trigger: "notin", replacement: "\\not\\in", options: "mA"},
{trigger: "\\subset eq", replacement: "\\subseteq", options: "mA"},
{trigger: "eset", replacement: "\\emptyset", options: "mA"},
{trigger: "set", replacement: "\\{ $0 \\}$1", options: "mA"},
{trigger: "=>", replacement: "\\implies", options: "mA"},
{trigger: "=<", replacement: "\\impliedby", options: "mA"},
{trigger: "iff", replacement: "\\iff", options: "mA"},
{trigger: "e\\xi sts", replacement: "\\exists", options: "mA", priority: 1},
{trigger: "===", replacement: "\\equiv", options: "mA"},
{trigger: "Sq", replacement: "\\square", options: "mA"},
{trigger: "!=", replacement: "\\neq", options: "mA"},
{trigger: ">=", replacement: "\\geq", options: "mA"},
{trigger: "<=", replacement: "\\leq", options: "mA"},
{trigger: ">>", replacement: "\\gg", options: "mA"},
{trigger: "<<", replacement: "\\ll", options: "mA"},
{trigger: "~~", replacement: "\\sim", options: "mA"},
{trigger: "\\sim ~", replacement: "\\approx", options: "mA"},
{trigger: "prop", replacement: "\\propto", options: "mA"},
{trigger: "nabl", replacement: "\\nabla", options: "mA"},
{trigger: "del", replacement: "\\nabla", options: "mA"},
{trigger: "xx", replacement: "\\times", options: "mA"},
{trigger: "**", replacement: "\\cdot", options: "mA"},
{trigger: "para", replacement: "\\parallel", options: "mA"},
{trigger: "xnn", replacement: "x_{n}", options: "mA"},
{trigger: "xii", replacement: "x_{i}", options: "mA"},
{trigger: "xjj", replacement: "x_{j}", options: "mA"},
{trigger: "xp1", replacement: "x_{n+1}", options: "mA"},
{trigger: "ynn", replacement: "y_{n}", options: "mA"},
{trigger: "yii", replacement: "y_{i}", options: "mA"},
{trigger: "yjj", replacement: "y_{j}", options: "mA"},
{trigger: "mcal", replacement: "\\mathcal{$0}$1", options: "mA"},
{trigger: "mbb", replacement: "\\mathbb{$0}$1", options: "mA"},
{trigger: "ell", replacement: "\\ell", options: "mA"},
{trigger: "lll", replacement: "\\ell", options: "mA"},
{trigger: "LL", replacement: "\\mathcal{L}", options: "mA"},
{trigger: "HH", replacement: "\\mathcal{H}", options: "mA"},
{trigger: "CC", replacement: "\\mathbb{C}", options: "mA"},
{trigger: "RR", replacement: "\\mathbb{R}", options: "mA"},
{trigger: "ZZ", replacement: "\\mathbb{Z}", options: "mA"},
{trigger: "NN", replacement: "\\mathbb{N}", options: "mA"},
{trigger: "II", replacement: "\\mathbb{1}", options: "mA"},
{trigger: "\\mathbb{1}I", replacement: "\\hat{\\mathbb{1}}", options: "mA"},
{trigger: "AA", replacement: "\\mathcal{A}", options: "mA"},
{trigger: "BB", replacement: "\\mathbf{B}", options: "mA"},
{trigger: "EE", replacement: "\\mathbf{E}", options: "mA"},
// Unit vectors
{trigger: ":i", replacement: "\\mathbf{i}", options: "mA"},
{trigger: ":j", replacement: "\\mathbf{j}", options: "mA"},
{trigger: ":k", replacement: "\\mathbf{k}", options: "mA"},
{trigger: ":x", replacement: "\\hat{\\mathbf{x}}", options: "mA"},
{trigger: ":y", replacement: "\\hat{\\mathbf{y}}", options: "mA"},
{trigger: ":z", replacement: "\\hat{\\mathbf{z}}", options: "mA"},
// Derivatives
{trigger: "par", replacement: "\\frac{ \\partial ${0:y} }{ \\partial ${1:x} } $2", options: "m"},
{trigger: "pa2", replacement: "\\frac{ \\partial^{2} ${0:y} }{ \\partial ${1:x}^{2} } $2", options: "mA"},
{trigger: "pa3", replacement: "\\frac{ \\partial^{3} ${0:y} }{ \\partial ${1:x}^{3} } $2", options: "mA"},
{trigger: "pa([A-Za-z])([A-Za-z])", replacement: "\\frac{ \\partial [[0]] }{ \\partial [[1]] } ", options: "rm"},
{trigger: "pa([A-Za-z])([A-Za-z])([A-Za-z])", replacement: "\\frac{ \\partial^{2} [[0]] }{ \\partial [[1]] \\partial [[2]] } ", options: "rm"},
{trigger: "pa([A-Za-z])([A-Za-z])2", replacement: "\\frac{ \\partial^{2} [[0]] }{ \\partial [[1]]^{2} } ", options: "rmA"},
{trigger: "de([A-Za-z])([A-Za-z])", replacement: "\\frac{ d[[0]] }{ d[[1]] } ", options: "rm"},
{trigger: "de([A-Za-z])([A-Za-z])2", replacement: "\\frac{ d^{2}[[0]] }{ d[[1]]^{2} } ", options: "rmA"},
{trigger: "ddt", replacement: "\\frac{d}{dt} ", options: "mA"},
// Integrals
{trigger: "oinf", replacement: "\\int_{0}^{\\infty} $0 \\, d${1:x} $2", options: "mA"},
{trigger: "infi", replacement: "\\int_{-\\infty}^{\\infty} $0 \\, d${1:x} $2", options: "mA"},
{trigger: "dint", replacement: "\\int_{${0:0}}^{${1:\\infty}} $2 \\, d${3:x} $4", options: "mA"},
{trigger: "oint", replacement: "\\oint", options: "mA"},
{trigger: "iiint", replacement: "\\iiint", options: "mA"},
{trigger: "iint", replacement: "\\iint", options: "mA"},
{trigger: "int", replacement: "\\int $0 \\, d${1:x} $2", options: "mA"},
// Physics
{trigger: "kbt", replacement: "k_{B}T", options: "mA"},
// Quantum mechanics
{trigger: "hba", replacement: "\\hbar", options: "mA"},
{trigger: "dag", replacement: "^{\\dagger}", options: "mA"},
{trigger: "o+", replacement: "\\oplus ", options: "mA"},
{trigger: "ox", replacement: "\\otimes ", options: "mA"},
{trigger: "ot\\mathrm{Im}es", replacement: "\\otimes ", options: "mA"}, // Handle conflict with "im" snippet
{trigger: "bra", replacement: "\\bra{$0} $1", options: "mA"},
{trigger: "ket", replacement: "\\ket{$0} $1", options: "mA"},
{trigger: "brk", replacement: "\\braket{ $0 | $1 } $2", options: "mA"},
{trigger: "\\\\bra{([^|]+)\\|", replacement: "\\braket{ [[0]] | $0 ", options: "rmA", description: "Convert bra into braket"},
{trigger: "\\\\bra{(.+)}([^ ]+)>", replacement: "\\braket{ [[0]] | $0 ", options: "rmA", description: "Convert bra into braket (alternate)"},
{trigger: "outp", replacement: "\\ket{${0:\\psi}} \\bra{${0:\\psi}} $1", options: "mA"},
// Chemistry
{trigger: "pu", replacement: "\\pu{ $0 }", options: "mA"},
{trigger: "msun", replacement: "M_{\\odot}", options: "mA"},
{trigger: "solm", replacement: "M_{\\odot}", options: "mA"},
{trigger: "cee", replacement: "\\ce{ $0 }", options: "mA"},
{trigger: "iso", replacement: "{}^{${0:4}}_{${1:2}}${2:He}", options: "mA"},
{trigger: "hel4", replacement: "{}^{4}_{2}He ", options: "mA"},
{trigger: "hel3", replacement: "{}^{3}_{2}He ", options: "mA"},
// Environments
{trigger: "pmat", replacement: "\\begin{pmatrix}\n$0\n\\end{pmatrix}", options: "MA"},
{trigger: "bmat", replacement: "\\begin{bmatrix}\n$0\n\\end{bmatrix}", options: "MA"},
{trigger: "Bmat", replacement: "\\begin{Bmatrix}\n$0\n\\end{Bmatrix}", options: "MA"},
{trigger: "vmat", replacement: "\\begin{vmatrix}\n$0\n\\end{vmatrix}", options: "MA"},
{trigger: "Vmat", replacement: "\\begin{Vmatrix}\n$0\n\\end{Vmatrix}", options: "MA"},
{trigger: "matrix", replacement: "\\begin{matrix}\n$0\n\\end{matrix}", options: "MA"},
{trigger: "pmat", replacement: "\\begin{pmatrix}$0\\end{pmatrix}", options: "nA"},
{trigger: "bmat", replacement: "\\begin{bmatrix}$0\\end{bmatrix}", options: "nA"},
{trigger: "Bmat", replacement: "\\begin{Bmatrix}$0\\end{Bmatrix}", options: "nA"},
{trigger: "vmat", replacement: "\\begin{vmatrix}$0\\end{vmatrix}", options: "nA"},
{trigger: "Vmat", replacement: "\\begin{Vmatrix}$0\\end{Vmatrix}", options: "nA"},
{trigger: "matrix", replacement: "\\begin{matrix}$0\\end{matrix}", options: "nA"},
{trigger: "case", replacement: "\\begin{cases}\n$0\n\\end{cases}", options: "mA"},
{trigger: "align", replacement: "\\begin{align}\n$0\n\\end{align}", options: "mA"},
{trigger: "array", replacement: "\\begin{array}\n$0\n\\end{array}", options: "mA"},
// Brackets
{trigger: "avg", replacement: "\\langle $0 \\rangle $1", options: "mA"},
{trigger: "norm", replacement: "\\lvert $0 \\rvert $1", options: "mA", priority: 1},
{trigger: "Norm", replacement: "\\lVert $0 \\rVert $1", options: "mA", priority: 1},
{trigger: "ceil", replacement: "\\lceil $0 \\rceil $1", options: "mA"},
{trigger: "floor", replacement: "\\lfloor $0 \\rfloor $1", options: "mA"},
{trigger: "mod", replacement: "|$0|$1", options: "mA"},
{trigger: "(", replacement: "(${VISUAL})", options: "mA"},
{trigger: "[", replacement: "[${VISUAL}]", options: "mA"},
{trigger: "{", replacement: "{${VISUAL}}", options: "mA"},
{trigger: "(", replacement: "($0)$1", options: "mA"},
{trigger: "{", replacement: "{$0}$1", options: "mA"},
{trigger: "[", replacement: "[$0]$1", options: "mA"},
{trigger: "lr(", replacement: "\\left( $0 \\right) $1", options: "mA"},
{trigger: "lr|", replacement: "\\left| $0 \\right| $1", options: "mA"},
{trigger: "lr{", replacement: "\\left\\{ $0 \\right\\} $1", options: "mA"},
{trigger: "lr[", replacement: "\\left[ $0 \\right] $1", options: "mA"},
{trigger: "lra", replacement: "\\left< $0 \\right> $1", options: "mA"},
// Misc
{trigger: "tayl", replacement: "${0:f}(${1:x} + ${2:h}) = ${0:f}(${1:x}) + ${0:f}'(${1:x})${2:h} + ${0:f}''(${1:x}) \\frac{${2:h}^{2}}{2!} + \\dots$3", options: "mA"},
{trigger: /iden(\d)/, replacement: (match) => {
const n = match[1];
let arr = [];
for (let j = 0; j < n; j++) {
arr[j] = [];
for (let i = 0; i < n; i++) {
arr[j][i] = (i === j) ? 1 : 0;
}
}
let output = arr.map(el => el.join(" & ")).join(" \\\\\n");
output = `\\begin{pmatrix}\n${output}\n\\end{pmatrix}`;
return output;
}, options: "mA", description: "N x N identity matrix"},
]