Skip to content

Instantly share code, notes, and snippets.

@CaesarOG
Last active January 8, 2024 01:50
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save CaesarOG/0b9e9c778675537f4ae2c96b03be1de8 to your computer and use it in GitHub Desktop.
Save CaesarOG/0b9e9c778675537f4ae2c96b03be1de8 to your computer and use it in GitHub Desktop.
LaTeX w/ VimTex, UltiSnips and Zathura

MIT Licence

Vim for quick and lightweight realtime LaTeX authoring

This serves as a thorough introduction to getting setup for all aspects of a Vim workflow for speedy LaTeX authoring using Vimtex with UltiSnip snippets and Zathura PDF viewer. Install instructions are specific for MacOS but these tools can also be installed on any Linux or Windows computer. Thanks to Gilles Castel, a Math undergrad from Belgium who came up with most snippets used, the Vim plugin setup and using Zathura in tandem. His repository with the original snippets is Found Here, and his blog post showcasing how various snippets work is Found Here.

  • Vim text editor serves as the foundation of the workflow, with Vimtex plugin for enabling LaTeX editing along with the UltiSnips plugin that enables shortcuts that expand to code snippets.

  • Zathura PDF viewer is used in tandem with Vim in a manner that changes to the LaTex are automatically reflected in the PDF output. The combination of these two tools allows for lightweight and speedy real time output on your LaTeX markdown.

Installation

back to header

The Vim that comes with MacOS will not suffice for this, a newer Vim and most of the other tools required will be installed with brew package manager. If you do not already have brew installed, proceed after installing via their official instructions.

Python 3

back to header

Many users who work with LaTeX in data-heavy disciplines nowadays tend to have the Anaconda distribution installed already with their PATH variable prefixed by "install_location"/anaconda3/bin; in this case you already have Python 3. If you don't have Anaconda, you may have still installed Python separately, check Python at your terminal and see if you get a version 3.X.X, and also check for the existence of pip3. ONLY IF these tools are not there, you'll need to run:

brew install python

At this point, python3 and pip3 are symlinked into /usr/local/bin and you can proceed.

Vim

back to header

Before installing Vim through brew, run alias python=python3. Now simply brew install vim and unalias python. Afterwards quit all your terminals; opening a new one and running vim --version | grep python should give you +python3 in the subsequent output. UltiSnips which uses Python interpolation for more powerful editable snippets requires a Vim instance bound to a Python 3.

Plugins And .vimrc

back to header

Copy over all text in the following .vimrc into your own at ~/.vimrc and save.

set tabstop=4
set shiftwidth=4
autocmd TextChanged,TextChangedI <buffer> silent write
set backspace=indent,eol,start

" Plugins will be downloaded under the specified directory.
call plug#begin('~/.vim/plugged')

" Declare the list of plugins.
Plug 'sirver/ultisnips'
    let g:UltiSnipsExpandTrigger = '<tab>'
    let g:UltiSnipsJumpForwardTrigger = '<tab>'
    let g:UltiSnipsJumpBackwardTrigger = '<s-tab>'

Plug 'lervag/vimtex'
    set nocompatible
    let &rtp = '~/.vim/plugged/vimtex,' . &rtp
    let &rtp .= ',~/.vim/plugged/vimtex/after'
    filetype plugin indent on
    syntax enable
    let g:vimtex_latexmk_continuous=0
    let g:tex_flavor='latex'
    let g:Tex_DefaultTargetFormat='pdf'
    let g:vimtex_view_enabled=1
    let g:vimtex_view_automatic=1
    let g:vimtex_view_general_viewer='zathura'
    let g:vimtex_view_method='zathura'
    let g:vimtex_quickfix_mode=0
    let g:vimtex_compiler_latexmk = { 
      \  'callback' : 0,
      \}

Plug 'KeitaNakamura/tex-conceal.vim'
    set conceallevel=1
    let g:tex_conceal='abdmg'
    hi Conceal ctermbg=none

Plug 'dylanaraps/wal'

" List ends here. Plugins become visible to Vim after this call.
call plug#end()

setlocal spell
set spelllang=en_us
inoremap <C-l> <c-g>u<Esc>[s1z=`]a<c-g>u
colorscheme wal
set background=dark
set rtp+=~/.vim/UltiSnips/greek

BEFORE running the plugin install command, if you don't have the iterm2 terminal app installed and further definitely don't want to either, omit the following two lines for Vim font (first line in plugin section, second at bottom):

Plug 'dylanaraps/wal'
colorscheme wal

Next, open vim from terminal and type :PlugInstall; every plugin mentioned in the .vimrc will be installed into ~/.vim/plugged as the location is specified in the .vimrc file.

(Again skip following to "For a few details..." if no iterm) A dependency of the dylanaraps/wal plugin must be installed, run sudo pip3 install pywal then wal --theme base16-nord . Copy the font file colors-wal.vim from the directory ~/.cache/wal, into directory ~/.vim, but also ensure to rename the file to wal.vim. Simply running:

mv ~/.cache/wal/colors-wal.vim ~/.vim/wal.vim

after the wal --theme command will accomplish all of this.

For a few details about the non-plugin aspects of the .vimrc, the first two lines set tab size to the size of 4 spaces since I find the default 8 to be obnoxious, and towards the end the inoremap is a spellcheck for typing normal English paragraphs in LaTeX documents, misspelled words are highlighted and you can hit Tab to correct them. Also, the set rtp sets Vim's runtimepath to include another directory you will add later (besides the main LaTeX snippets you will add) to include LaTeX snippets for Greek letters. A gif showing inoremap spelling correction in action can be found in Gilles' blog post mentioned at The Top.

Vimtex Dependencies

back to header

Vimtex requires additional binaries in order to work, that will compile the LaTeX document on user input and output a PDF which you will have open in Zathura side by side. First get the BasicTex distribution which is 90Mb, this is the Direct Download Link; Right-Click & Save As. The page the BasicTex download link is available at is Found Here, which itself is linked in this Doc Page for LatexTools. Go through the install process; it will unpack the binaries into /usr/local/texlive/2019basic/bin/x86_64-darwin. Do a cd into that directory, because there is still one more binary latexmk which they strangely decided not to include in the pkg file, I say strange since it does the actual compiling! In the directory, call its tlmgr binary to install latexmk -> sudo tlmgr install latexmk. And end it off with the necessary soft link:

sudo ln -s /usr/local/texlive/2019basic/bin/x86_64-darwin/latexmk /usr/local/bin

You don't need to do this following step (another soft link) UNLESS you later get the error bibtex not executable while in the Usage section (mostly doesn't happen); if you do then remember to come here and repeat the soft link but change latexmk to bibtex.

The Snippets! (finally)

back to header

The snippets are prohibitively long to directly include in this markdown file, but they are in this same Gist. Scroll down and see the files tex.snippets and greek/tex.snippets. The former goes in ~/.vim/UltiSnips directory, and the latter goes in ~/.vim/UltiSnips/greek/UltiSnips (remove greek_ from filename!); you'll have to mkdir greek/UltiSnips (which makes both, nested) from inside ~/.vim/UltiSnips first.

Zathura

back to header

The following instructions come from this repository. Run brew tap zegervdv/zathura, then brew install zathura and brew install zathura-pdf-poppler. Next you'll need to link the plugins into place:

$ mkdir -p $(brew --prefix zathura)/lib/zathura
$ ln -s $(brew --prefix zathura-pdf-poppler)/libpdf-poppler.dylib $(brew --prefix zathura)/lib/zathura/libpdf-poppler.dylib

Usage

back to header

Close all open terminals and open a new one, and open up a .tex file with vim <filename.tex>. Start off a basic document with:

\documentclass{article}
beg

You'll immediately notice that as you type beg, it automatically expands to:

\begin{}

\end{}

with the cursor inside the curly brackets at \begin. Here, type document, which will add the same word inside the \end tag, and hitting Tab afterwards will bring you inside the two tags. Type some text, then to try another snippet first Esc out of Insert mode and hit v for Visual mode, and select the text you just typed by option+click at the beginning and another option+click at the end. With the text highlighted, hit Tab which deletes the text, type lr then hit Tab again which will bring back the text surrounded by \left( and \right) parentheses. This begins to show you the full power of the UltiSnip plugin, which also lets you use regex as part of Python interpolation in snippet expansion. How text selected in Visual mode can be captured to be used in a snippet is Explained Here. Hit Esc and then \ll, this will start the Vimtex compiler in continuous mode, then in another window/tab go to the same directory where your new name.tex file is and run zathura name.pdf & and disown. Watch as each keystroke re-renders the PDF, enjoy :) .

Final Notes

back to header

I've modified Gilles' subscript2 snippet in the main tex.snippets file such that x_\ also expands to x_{} and leaves the cursor inside so you can type greek letters. So por ejemplo, x_\ + th + Tab expands to x_{\theta}. Notice there was no Tab for x_\, this is because the subscript notation itself is configured to autoexpand since the headline of the snippet ends in A, only the greek letters require a Tab to prevent undesired autoexpansion as MANY other LaTeX keywords can start with the same a-z letter of alphabet so \"letter" would infuriatingly give you a greek letter when you meant to type another keyword.

Any snippet (such as the subscript ones) you see with context math() as its first line will only work inside math contexts, which Gilles has defined as:

  1. inside a dm block:

(typing dm autoexpands to

[/
	
/]

which is multiline math),

OR

  1. inside amk block:

(typing mk autoexpands to

$ $

which is single line math) .

There is truly SO MUCH you can do with UltiSnips, Gilles also has a sympy snippet where with the sympy module installed via pip, you can do symbolic integration and differentiation and it outputs LaTeX. So sympy + Tab + integrate(tanh(x),x) + Tab gives you:

x - \log{\left(\tanh{\left(x \right)} + 1 \right)}

!!!!

Links Section (docs and solved issues w/ answers, from which this readme has been compiled)

back to header

https://www.reddit.com/r/vim/comments/7c7wd9/vim_vimtex_zathura_on_macos/

https://stackoverflow.com/questions/40077211/e185-cannot-find-color-scheme

morhetz/gruvbox#219

junegunn/vim-plug#325

https://github.com/dylanaraps/pywal/wiki/Getting-Started

https://github.com/dylanaraps/wal.vim

https://github.com/dylanaraps/pywal/wiki/Customization

lervag/vimtex#1420

https://latextools.readthedocs.io/en/latest/install/

https://mg.readthedocs.io/latexmk.html

https://gist.github.com/LucaCappelletti94/920186303d71c85e66e76ff989ea6b62

lervag/vimtex#1420

https://latextools.readthedocs.io/en/latest/install/

lervag/vimtex#1420

lervag/vimtex#940

lervag/vimtex#663

http://www.math.cmu.edu/~gautam/sj/blog/20140310-zathura-fsearch.html

https://gitter.im/SirVer/ultisnips

SirVer/ultisnips#1107

SirVer/ultisnips#1022

SirVer/ultisnips#850

https://superuser.com/questions/1115159/how-do-i-install-vim-on-osx-with-python-3-support

https://jdhao.github.io/2020/01/05/ultisnips_python_interpolation/

http://witkowskibartosz.com/blog/python_snippets_in_vim_with_ultisnips.html#.Xnw9gtP7TRY

https://germaniumhq.com/2019/02/07/2019-02-07-Vim-Ultimate-Editing:-UltiSnips/

http://vimcasts.org/episodes/ultisnips-python-interpolation/

https://wraihan.com/posts/vimtex-and-zathura/

priority 0
snippet \G "Gamma" i
\Gamma
endsnippet
snippet \D "Delta" i
\Delta
endsnippet
snippet \L "Lambda" i
\Lambda
endsnippet
snippet \F "Phi" i
\Phi
endsnippet
snippet \P "Pi" i
\Pi
endsnippet
snippet \C "Psi" i
\Psi
endsnippet
snippet \S "Sigma" i
\Sigma
endsnippet
snippet \Th "Theta" i
\Theta
endsnippet
snippet \Y "Upsilon" i
\Upsilon
endsnippet
snippet \J "Xi" i
\Xi
endsnippet
snippet \O "Omega" i
\Omega
endsnippet
snippet \a "alpha" i
\alpha
endsnippet
snippet \b "beta" i
\beta
endsnippet
snippet \g "gamma" i
\gamma
endsnippet
snippet \d "delta" i
\delta
endsnippet
snippet \e "epsilon" i
\epsilon
endsnippet
snippet \z "zeta" i
\zeta
endsnippet
snippet \h "eta" i
\eta
endsnippet
snippet \th "theta" i
\theta
endsnippet
snippet \i "iota" i
\iota
endsnippet
snippet \k "kappa" i
\kappa
endsnippet
snippet \l "lambda" i
\lambda
endsnippet
snippet \m "mu" i
\mu
endsnippet
snippet \n "nu" i
\nu
endsnippet
snippet \j "xi" i
\xi
endsnippet
snippet \p "pi" i
\pi
endsnippet
snippet \r "rho" i
\rho
endsnippet
snippet \s "sigma" i
\sigma
endsnippet
snippet \t "tau" i
\tau
endsnippet
snippet \y "upsilon" i
\upsilon
endsnippet
snippet \f "phi" i
\phi
endsnippet
snippet \x "chi" i
\chi
endsnippet
snippet \c "psi" i
\psi
endsnippet
snippet \o "omega" i
\omega
endsnippet
snippet \dg "digamma" i
\digamma
endsnippet
snippet \ve "varepsilon" i
\varepsilon
endsnippet
snippet \vf "varphi" i
\varphi
endsnippet
snippet \vp "varpi" i
\varpi
endsnippet
snippet \vr "varrho" i
\varrho
endsnippet
snippet \vs "varsigma" i
\varsigma
endsnippet
snippet \vu "vartheta" i
\vartheta
endsnippet
global !p
texMathZones = ['texMathZone'+x for x in ['A', 'AS', 'B', 'BS', 'C', 'CS', 'D', 'DS', 'E', 'ES', 'F', 'FS', 'G', 'GS', 'H', 'HS', 'I', 'IS', 'J', 'JS', 'K', 'KS', 'L', 'LS', 'DS', 'V', 'W', 'X', 'Y', 'Z']]
texIgnoreMathZones = ['texMathText']
texMathZoneIds = vim.eval('map('+str(texMathZones)+", 'hlID(v:val)')")
texIgnoreMathZoneIds = vim.eval('map('+str(texIgnoreMathZones)+", 'hlID(v:val)')")
ignore = texIgnoreMathZoneIds[0]
def math():
synstackids = vim.eval("synstack(line('.'), col('.') - (col('.')>=2 ? 1 : 0))")
try:
first = next(i for i in reversed(synstackids) if i in texIgnoreMathZoneIds or i in texMathZoneIds)
return first != ignore
except StopIteration:
return False
endglobal
snippet template "Basic template" b
\documentclass[a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{textcomp}
\usepackage[dutch]{babel}
\usepackage{amsmath, amssymb}
% figure support
\usepackage{import}
\usepackage{xifthen}
\pdfminorversion=7
\usepackage{pdfpages}
\usepackage{transparent}
\newcommand{\incfig}[1]{%
\def\svgwidth{\columnwidth}
\import{./figures/}{#1.pdf_tex}
}
\pdfsuppresswarningpagegroup=1
\begin{document}
$0
\end{document}
endsnippet
snippet beg "begin{} / end{}" bA
\\begin{$1}
$0
\\end{$1}
endsnippet
priority 100
snippet ... "ldots" iA
\ldots
endsnippet
snippet table "Table environment" b
\begin{table}[${1:htpb}]
\centering
\caption{${2:caption}}
\label{tab:${3:label}}
\begin{tabular}{${5:c}}
$0${5/((?<=.)c|l|r)|./(?1: & )/g}
\end{tabular}
\end{table}
endsnippet
snippet fig "Figure environment" b
\begin{figure}[${1:htpb}]
\centering
${2:\includegraphics[width=0.8\textwidth]{$3}}
\caption{${4:$3}}
\label{fig:${5:${3/\W+/-/g}}}
\end{figure}
endsnippet
snippet enum "Enumerate" bA
\begin{enumerate}
\item $0
\end{enumerate}
endsnippet
snippet item "Itemize" bA
\begin{itemize}
\item $0
\end{itemize}
endsnippet
snippet desc "Description" b
\begin{description}
\item[$1] $0
\end{description}
endsnippet
snippet pac "Package" b
\usepackage[${1:options}]{${2:package}}$0
endsnippet
snippet => "implies" Ai
\implies
endsnippet
snippet =< "implied by" Ai
\impliedby
endsnippet
context "math()"
snippet iff "iff" Ai
\iff
endsnippet
snippet mk "Math" wA
$${1}$`!p
if t[2] and t[2][0] not in [',', '.', '?', '-', ' ']:
snip.rv = ' '
else:
snip.rv = ''
`$2
endsnippet
snippet dm "Math" wA
\[
${1:${VISUAL}}
\] $0
endsnippet
snippet ali "Align" bA
\begin{align*}
${1:${VISUAL}}
.\end{align*}
endsnippet
context "math()"
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet
snippet / "Fraction" i
\\frac{${VISUAL}}{$1}$0
endsnippet
context "math()"
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "symbol frac" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet
priority 1000
context "math()"
snippet '^.*\)/' "() frac" wrA
`!p
stripped = match.string[:-1]
depth = 0
i = len(stripped) - 1
while True:
if stripped[i] == ')': depth += 1
if stripped[i] == '(': depth -= 1
if depth == 0: break;
i-=1
snip.rv = stripped[0:i] + "\\frac{" + stripped[i+1:-1] + "}"
`{$1}$0
endsnippet
context "math()"
snippet '([A-Za-z])(\d)' "auto subscript" wrA
`!p snip.rv = match.group(1)`_`!p snip.rv = match.group(2)`
endsnippet
context "math()"
snippet '([A-Za-z])_(\d|[a-z]|\\)' "auto subscript2" wrA
`!p snip.rv = match.group(1)`_{`!p snip.rv = match.group(2)`$0}
endsnippet
snippet sympy "sympyblock " w
sympy $1 sympy$0
endsnippet
priority 10000
snippet 'sympy(.*)sympy' "sympy" wr
`!p
from sympy import *
x, y, z, t = symbols('x y z t')
k, m, n = symbols('k m n', integer=True)
f, g, h = symbols('f g h', cls=Function)
init_printing()
snip.rv = eval('latex(' + match.group(1).replace('\\', '').replace('^', '**').replace('{', '(').replace('}', ')') + ')')
`
endsnippet
priority 1000
snippet math "mathematicablock" w
math $1 math$0
endsnippet
priority 10000
snippet 'math(.*)math' "math" wr
`!p
import subprocess
code = match.group(1)
code = 'ToString[' + code + ', TeXForm]'
snip.rv = subprocess.check_output(['wolframscript', '-code', code])
`
endsnippet
snippet == "equals" iA
&= $1 \\\\
endsnippet
snippet != "equals" iA
\neq
endsnippet
context "math()"
snippet ceil "ceil" iA
\left\lceil $1 \right\rceil $0
endsnippet
context "math()"
snippet floor "floor" iA
\left\lfloor $1 \right\rfloor$0
endsnippet
snippet pmat "pmat" iA
\begin{pmatrix} $1 \end{pmatrix} $0
endsnippet
snippet bmat "bmat" iA
\begin{bmatrix} $1 \end{bmatrix} $0
endsnippet
snippet ( "parens ()" iA
($0)
endsnippet
snippet lr "left( right)" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr( "left( right)" i
\left( ${1:${VISUAL}} \right) $0
endsnippet
snippet lr| "left| right|" i
\left| ${1:${VISUAL}} \right| $0
endsnippet
snippet lr{ "left\{ right\}" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
snippet lrb "left\{ right\}" i
\left\\{ ${1:${VISUAL}} \right\\} $0
endsnippet
snippet lr[ "left[ right]" i
\left[ ${1:${VISUAL}} \right] $0
endsnippet
snippet lra "leftangle rightangle" iA
\left<${1:${VISUAL}} \right>$0
endsnippet
context "math()"
snippet conj "conjugate" iA
\overline{$1}$0
endsnippet
snippet sum "sum" w
\sum_{${1:i=1}}^{${2:\infty}} ${3:a_n z^n}
endsnippet
snippet taylor "taylor" w
\sum_{${1:k}=${2:0}}^{${3:\infty}} ${4:c_$1} (x-a)^$1 $0
endsnippet
snippet lim "limit" w
\lim_{${1:n} \to ${2:\infty}}
endsnippet
snippet limsup "limsup" w
\limsup_{${1:n} \to ${2:\infty}}
endsnippet
snippet prod "product" w
\prod_{${1:n=${2:1}}}^{${3:\infty}} ${4:${VISUAL}} $0
endsnippet
snippet part "d/dx" w
\frac{\partial ${1:V}}{\partial ${2:x}} $0
endsnippet
context "math()"
snippet sq "\sqrt{}" iA
\sqrt{${1:${VISUAL}}} $0
endsnippet
context "math()"
snippet sr "^2" iA
^2
endsnippet
context "math()"
snippet cb "^3" iA
^3
endsnippet
context "math()"
snippet td "to the ... power" iA
^{$1}$0
endsnippet
context "math()"
snippet rd "to the ... power" iA
^{($1)}$0
endsnippet
snippet __ "subscript" iA
_{$1}$0
endsnippet
snippet ooo "\infty" iA
\infty
endsnippet
snippet rij "mrij" i
(${1:x}_${2:n})_{${3:$2}\\in${4:\\N}}$0
endsnippet
snippet <= "leq" iA
\le
endsnippet
snippet >= "geq" iA
\ge
endsnippet
context "math()"
snippet EE "geq" iA
\exists
endsnippet
context "math()"
snippet AA "forall" iA
\forall
endsnippet
context "math()"
snippet xnn "xn" iA
x_{n}
endsnippet
context "math()"
snippet ynn "yn" iA
y_{n}
endsnippet
context "math()"
snippet xii "xi" iA
x_{i}
endsnippet
context "math()"
snippet yii "yi" iA
y_{i}
endsnippet
context "math()"
snippet xjj "xj" iA
x_{j}
endsnippet
context "math()"
snippet yjj "yj" iA
y_{j}
endsnippet
context "math()"
snippet xp1 "x" iA
x_{n+1}
endsnippet
context "math()"
snippet xmm "x" iA
x_{m}
endsnippet
snippet R0+ "R0+" iA
\\R_0^+
endsnippet
snippet plot "Plot" w
\begin{figure}[$1]
\centering
\begin{tikzpicture}
\begin{axis}[
xmin= ${2:-10}, xmax= ${3:10},
ymin= ${4:-10}, ymax = ${5:10},
axis lines = middle,
]
\addplot[domain=$2:$3, samples=${6:100}]{$7};
\end{axis}
\end{tikzpicture}
\caption{$8}
\label{${9:$8}}
\end{figure}
endsnippet
snippet nn "Tikz node" w
\node[$5] (${1/[^0-9a-zA-Z]//g}${2}) ${3:at (${4:0,0}) }{$${1}$};
$0
endsnippet
context "math()"
snippet mcal "mathcal" iA
\mathcal{$1}$0
endsnippet
snippet lll "l" iA
\ell
endsnippet
context "math()"
snippet nabl "nabla" iA
\nabla
endsnippet
context "math()"
snippet xx "cross" iA
\times
endsnippet
priority 100
snippet ** "cdot" iA
\cdot
endsnippet
context "math()"
snippet norm "norm" iA
\|$1\|$0
endsnippet
priority 100
context "math()"
snippet '(?<!\\)(sin|cos|arccot|cot|csc|ln|log|exp|star|perp)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet
priority 300
context "math()"
snippet dint "integral" wA
\int_{${1:-\infty}}^{${2:\infty}} ${3:${VISUAL}} $0
endsnippet
priority 200
context "math()"
snippet '(?<!\\)(arcsin|arccos|arctan|arccot|arccsc|arcsec|pi|zeta|int)' "ln" rwA
\\`!p snip.rv = match.group(1)`
endsnippet
priority 100
context "math()"
snippet -> "to" iA
\to
endsnippet
priority 200
context "math()"
snippet <-> "leftrightarrow" iA
\leftrightarrow
endsnippet
context "math()"
snippet !> "mapsto" iA
\mapsto
endsnippet
context "math()"
snippet invs "inverse" iA
^{-1}
endsnippet
context "math()"
snippet compl "complement" iA
^{c}
endsnippet
context "math()"
snippet \\\ "setminus" iA
\setminus
endsnippet
snippet >> ">>" iA
\gg
endsnippet
snippet << "<<" iA
\ll
endsnippet
snippet ~~ "~" iA
\sim
endsnippet
context "math()"
snippet set "set" wA
\\{$1\\} $0
endsnippet
snippet || "mid" iA
\mid
endsnippet
context "math()"
snippet cc "subset" Ai
\subset
endsnippet
snippet notin "not in " iA
\not\in
endsnippet
context "math()"
snippet inn "in " iA
\in
endsnippet
snippet NN "n" iA
\N
endsnippet
snippet Nn "cap" iA
\cap
endsnippet
snippet UU "cup" iA
\cup
endsnippet
snippet uuu "bigcup" iA
\bigcup_{${1:i \in ${2: I}}} $0
endsnippet
snippet nnn "bigcap" iA
\bigcap_{${1:i \in ${2: I}}} $0
endsnippet
snippet OO "emptyset" iA
\O
endsnippet
snippet RR "real" iA
\R
endsnippet
snippet QQ "Q" iA
\Q
endsnippet
snippet ZZ "Z" iA
\Z
endsnippet
snippet <! "normal" iA
\triangleleft
endsnippet
snippet <> "hokje" iA
\diamond
endsnippet
context "math()"
snippet '(?<!i)sts' "text subscript" irA
_\text{$1} $0
endsnippet
context "math()"
snippet tt "text" iA
\text{$1}$0
endsnippet
context "math()"
snippet case "cases" wA
\begin{cases}
$1
\end{cases}
endsnippet
snippet SI "SI" iA
\SI{$1}{$2}
endsnippet
snippet bigfun "Big function" iA
\begin{align*}
$1: $2 &\longrightarrow $3 \\\\
$4 &\longmapsto $1($4) = $0
.\end{align*}
endsnippet
snippet cvec "column vector" iA
\begin{pmatrix} ${1:x}_${2:1}\\\\ \vdots\\\\ $1_${2:n} \end{pmatrix}
endsnippet
priority 10
context "math()"
snippet "bar" "bar" riA
\overline{$1}$0
endsnippet
priority 100
context "math()"
snippet "([a-zA-Z])bar" "bar" riA
\overline{`!p snip.rv=match.group(1)`}
endsnippet
priority 10
context "math()"
snippet "hat" "hat" riA
\hat{$1}$0
endsnippet
priority 100
context "math()"
snippet "([a-zA-Z])hat" "hat" riA
\hat{`!p snip.rv=match.group(1)`}
endsnippet
context "math()"
snippet "dot" "dot" riA
\dot{$1}$0
endsnippet
context "math()"
snippet "arw" "arw" riA
\overrightarrow{$1}$0
endsnippet
snippet letw "let omega" iA
Let $\Omega \subset \C$ be open.
endsnippet
snippet HH "H" iA
\mathbb{H}
endsnippet
snippet DD "D" iA
\mathbb{D}
endsnippet
snippet box "Box"
`!p snip.rv = '┌' + '─' * (len(t[1]) + 2) + '┐'`
│ $1 │
`!p snip.rv = '└' + '─' * (len(t[1]) + 2) + '┘'`
$0
endsnippet
snippet today "Date"
`date +%F`
endsnippet
# vim:ft=snippets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment