This is the relevant configuration to have YASnippet ready:
Code: Select all
(use-package yasnippet ; Snippets
:ensure t
:init (yas-global-mode)
:config
(progn
(setq yas-verbosity 1 ; No need to be so verbose
yas-wrap-around-region t))
Code: Select all
~ % ls .emacs.d/snippets
clojure-mode emacs-lisp-mode html-mode latex-mode
Code: Select all
# -*- mode: snippet -*-
# name: textbf
# key: b
# --
\textbf{$0}
Now, see that "key: b" in the snippet code? Exactly. Type b and then hit TAB in your usual .tex file and voilà: magic happens.
Snippets can save a lot of typing. This is for the tables I usually need in my LaTeX documents:
Code: Select all
# -*- mode: snippet -*-
# name: table
# key: table
# --
\begin{table}[!htb]
\centering
\begin{threeparttable}
\renewcommand{\arraystretch}{1.5}
\begin{tabular}{${0:format}}
\end{tabular}
\end{threeparttable}
\end{table}
Code: Select all
# -*- mode: snippet -*-
# name: html
# key: html
# --
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>$1</title>
</head>
<body>
$0
</body>
</html>