I am attempting to use the following sublime snippet for using in quickly creating LaTeX documents:
<snippet>
<content><![CDATA[
\def\HWset{$1}
\def\myname{MyName}
\documentclass{CustomClassFromMyProfessor}
\usepackage{bigints}
\usepackage{amsmath}
\usepackage{tikz}
\newcommand{\cord}{\coordinate}
\newcommand\ddfrac[2]{\frac{\displaystyle #1}{\displaystyle #2}}
\newcommand{\eps}{\epsilon}
\newcommand{\p}{\partial}
\newcommand{\er}{\bv{e}_r}
\newcommand{\ephi}{\bv{e}_\varphi}
\newcommand{\etheta}{\bv{e}_{\theta}}
\newcommand{\ez}{\bv{e}_z}
\newcommand{\ex}{\bv{e}_x}
\newcommand{\ey}{\bv{e}_y}
\newcommand{\qed}{$\hfill\blacksquare$\\}
\usepackage{mathtools}
\DeclarePairedDelimiter\br{\langle}{\rvert}
\DeclarePairedDelimiter\kt{\lvert}{\rangle}
\DeclarePairedDelimiterX\brkt[2]{\langle}{\rangle}{#1 \delimsize\vert #2}
\newcommand\brktt[3]{\left< #1 \right| #2 \left| #3 \right>}
\begin{document}
\textbf{$2}
\makeHWtitle
\problem{$3}
$4
\end{document}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>newhw</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.python</scope> -->
</snippet>
However, when I attempt to actually use it typing out: newhw
then pressing tab simply erases newhw
without inserting anything.
This snippet was actually working at some point, so I am confused why it stopped. Also I am aware that I should probably just create my own document class, but this sounds rather daunting, especially since I would have to incorporate the custom class that I did not write, however I haven't really looked into this.
The body of your snippet has some invalid text in it because it has some unescaped $
characters on line 19: \newcommand{\qed}{$\hfill\blacksquare$\\}
. Prefixing each of them with a \
character to tell Sublime that the following $
character is not special will fix the problem.
As background, the $
character is special in a snippet (and in various other places in Sublime where variables are supported for expansion) and represents the name of the variable to expand (or in the case of a snippet, a placeholder for a field).
Generally when you you specify a variable that doesn't exist (e.g. $cool
), the result is that the variable expands out to be an empty string. In this particular case, the variables look like $\
and $\\
, which isn't a valid variable name. Behind the scenes the entire expansion is failing, which makes the entire snippet insertion fail.
As a general recommendation (with no affiliation at all) the PackageDev package includes amongst its features enhanced syntax highlighting for various Sublime file types, which can make these sorts of problems more obvious. For example, here you can see that the unescaped $
characters are highlighted as invalid (and the placeholders are highlighted as well):