-
Notifications
You must be signed in to change notification settings - Fork 29
Live Snippets
Live Snippets are much like normal snippets, however, they can do a few more things, namely:
- Include RegEx
- Auto-activate
- Be specific to Text/Maths LaTeX scopes
This extension comes with a default set of snippets liveSnippets.json, however they are disabled by default. To enable Live Snippets set latex-utilities.liveReformat.enabled
to true
.
Due to difficulties in parsing inline math formula$$
, math-related live snippets are only supported in \(\)
-style inline formulas and display style formulas (\[\]
, \begin{equation}
)
You can customize the live snippets with the command "Edit Live Snippets File". Do note that this makes a copy of liveSnippets.json in your user config folder; this means that any changes to the default snippets file will no longer be propagated. To undo this simply delete that file.
Important: if you run the "Edit Live Snippets File" command you need to delete the opened file to continue receiving updates to the default live snippets
For those writing your own snippets, if you want to avoid the snippet triggering on commands then you may find having "prefix": "(^|[^\\\\])\\b...
and then "body": "$1...
to be handy.
interface ISnippet {
prefix: string // Escaped RegEx Test String
body: string // Replacement Text. Use $1 for regex groups, and $$1 for tabstops
description?: string // just for you
priority?: number // affects order in which prefixes are tested
triggerWhenComplete?: boolean // insta-complete. Off by default
mode?: 'maths' | 'text' | 'any' // Specific LaTeX mode. 'any' by default
noPlaceholders?: boolean // unless set, this is worked out from the presence of $$ in the body
}
Because regex isn't easy to read, this is what you can expect with the default snippets.
Trigger | Replacement |
---|---|
a1 |
a_1 |
a_11 |
a_{11} |
a ^ |
a^ |
a^11 |
a^{11} |
a+ |
a + |
a +b |
a + b |
... |
\dots |
=> |
\implies |
=< |
\impliedby |
// |
\frac{}{} |
.../ |
\frac{...}{} |
iff |
\iff |
inn |
\in |
notin |
\not\in |
!= |
\neq |
== |
&= |
~= |
\approx |
~~ |
\sim |
>= |
\geq |
<= |
\leq |
>> |
\gg |
<< |
\ll |
xx |
\times |
** |
\cdot |
to |
\to |
-> |
\to |
|-> |
\mapsto |
!> |
\mapsto |
sin |
\sin |
v,. |
\vec{v} |
abar |
\overline{a} |
ahat |
\hat{a} |
a~ |
\tilde{a} |
a. |
\dot{a} |
a.. |
\ddot{a} |
...\)a |
...\) a |
\\\ |
\setminus |
pmat |
pmatrix |
part |
\frac{\partial }{\partial } |
sq |
\sqrt{} |
sr |
^2 |
cb |
^3 |
EE |
\exists |
AA |
\forall |
aii |
a_i |
aip1 |
a_{i+1} |
set |
\{ \} |
|| |
\mid |
<> |
\diamond |
case |
cases env. |
st |
\text{s.t.} |
+- |
\pm |
-+ |
\mp |
nCr |
\binom{n}{r} |