From 872f0e5e0e9c1d6e2e10be0774e05d3426ada565 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Wed, 31 Jan 2018 00:03:56 -0500 Subject: [PATCH 1/3] Generic for, alias and multi-line equation For C, bash and LaTeX respectively. --- c.snippets | 5 +++++ sh.snippets | 3 +++ texmath.snippets | 7 +++++++ 3 files changed, 15 insertions(+) create mode 100644 c.snippets create mode 100644 sh.snippets create mode 100644 texmath.snippets diff --git a/c.snippets b/c.snippets new file mode 100644 index 0000000..b213a7f --- /dev/null +++ b/c.snippets @@ -0,0 +1,5 @@ +snippet forg "Generic for" +for (int i = 0; i < ${1:count}; i++) { + ${2} +} +endsnippet diff --git a/sh.snippets b/sh.snippets new file mode 100644 index 0000000..9256604 --- /dev/null +++ b/sh.snippets @@ -0,0 +1,3 @@ +snippet alias "Custom alias" +alias ${1:name}="${2:command}" +endsnippet diff --git a/texmath.snippets b/texmath.snippets new file mode 100644 index 0000000..c5a7018 --- /dev/null +++ b/texmath.snippets @@ -0,0 +1,7 @@ +snippet eqs "Equation with split" b +\begin{equation*} + \begin{split} + $0 + \end{split} +\end{equation*} +endsnippet From 8877960762699dd025957010f5172b520f0edf0c Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Wed, 31 Jan 2018 01:58:04 -0500 Subject: [PATCH 2/3] snippets (new), Bash functions - LaTeX: align, piecewise function - snippets: tabstops, LaTeX environment - .gitignore --- .gitignore | 1 + sh.snippets | 15 +++++++++++++-- snippets.snippets | 10 ++++++++++ texmath.snippets | 20 ++++++++++++++------ 4 files changed, 38 insertions(+), 8 deletions(-) create mode 100644 .gitignore create mode 100644 snippets.snippets diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1ee84da --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.sw* diff --git a/sh.snippets b/sh.snippets index 9256604..fa89b73 100644 --- a/sh.snippets +++ b/sh.snippets @@ -1,3 +1,14 @@ snippet alias "Custom alias" -alias ${1:name}="${2:command}" -endsnippet +alias ${1:name}="${2:cmd}" +endsnippet + +snippet 1lf "One-line function" +${1:name}() { ${2:cmd} ; } +endsnippet + +snippet mlf "Multi-line function" +${1:name}() { + ${2:cmd} +} +endsnippet + diff --git a/snippets.snippets b/snippets.snippets new file mode 100644 index 0000000..afc73ef --- /dev/null +++ b/snippets.snippets @@ -0,0 +1,10 @@ +snippet ts "Tabstop" +${${1:number}:${2:default}} +endsnippet + +snippet "b(egin)?" "begin{} / end{}" br +\begin{${1:something}} + ${0:${VISUAL}} +\end{$1} +endsnippet + diff --git a/texmath.snippets b/texmath.snippets index c5a7018..0f8d977 100644 --- a/texmath.snippets +++ b/texmath.snippets @@ -1,7 +1,15 @@ -snippet eqs "Equation with split" b -\begin{equation*} - \begin{split} - $0 - \end{split} -\end{equation*} +snippet al "Align (math)" b +\begin{align*} + $0 +\end{align*} +endsnippet + +snippet pwf "Piecewise function" b +\[ + ${1:name} = \left. + \begin{cases} + ${2:equation}, & ${3:condition} \\\\ + \end{cases} + \right\\} +\] endsnippet From 9103500922e120c05e1e6a885ef18cde14303f85 Mon Sep 17 00:00:00 2001 From: Kevin Mok Date: Thu, 1 Feb 2018 16:59:44 -0500 Subject: [PATCH 3/3] C: malloc, str functions | TeX: integral, bold - sh: var with quotes --- c.snippets | 16 ++++++++++++++++ sh.snippets | 8 ++++++++ snippets.snippets | 2 +- tex.snippets | 7 +++++++ texmath.snippets | 4 ++++ 5 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 tex.snippets diff --git a/c.snippets b/c.snippets index b213a7f..056476e 100644 --- a/c.snippets +++ b/c.snippets @@ -3,3 +3,19 @@ for (int i = 0; i < ${1:count}; i++) { ${2} } endsnippet + +snippet mlc "malloc" i += malloc(sizeof(${1:type}) * ${2:amt}); +endsnippet + +snippet stl "strlen" +strlen(${1:var}) +endsnippet + +snippet scp "strcpy" +strcpy(${1:dest}, ${2:str}); +endsnippet + +snippet cmt "Line comment" b +/* ${1:text} */ +endsnippet diff --git a/sh.snippets b/sh.snippets index fa89b73..5067f8c 100644 --- a/sh.snippets +++ b/sh.snippets @@ -12,3 +12,11 @@ ${1:name}() { } endsnippet +snippet evr "Var with escaped quotes" i +\"$${1:var}\" +endsnippet + +snippet vr "Var with quotes" i +"$${1:var}" +endsnippet + diff --git a/snippets.snippets b/snippets.snippets index afc73ef..5b71e97 100644 --- a/snippets.snippets +++ b/snippets.snippets @@ -1,4 +1,4 @@ -snippet ts "Tabstop" +snippet ts "Tabstop" i ${${1:number}:${2:default}} endsnippet diff --git a/tex.snippets b/tex.snippets new file mode 100644 index 0000000..ed92608 --- /dev/null +++ b/tex.snippets @@ -0,0 +1,7 @@ +snippet bf "Boldface" i +\textbf{$0} +endsnippet + +snippet geq "Geq eqn" i +$\geq $0$ +endsnippet diff --git a/texmath.snippets b/texmath.snippets index 0f8d977..5f118bc 100644 --- a/texmath.snippets +++ b/texmath.snippets @@ -13,3 +13,7 @@ snippet pwf "Piecewise function" b \right\\} \] endsnippet + +snippet int "Integral" i +\int_{${1:lower}}^{${2:upper}} \, \mathrm{d}${3:x} +endsnippet