I am trying to define a snippet which substitutes text in multiple places. As a trivial example see the following which works for me :
snippet abc "Testing" bmA
\begin{${1:text_here}}
$0
\end{${1:text_here}}
Now, when this snippet is expanded whatever I substitute for text_here
in the first instance gets automatically substituted in the second instance as well. I want to expand this to write the preamble of my code as follows :
snippet notes "creates a template to take notes" bm
% !TEX program = xelatex
\documentclass[${1:12pt}]{${2:article}}
\usepackage[fleqn]{amsmath}
\usepackage{amssymb}
\usepackage{bm} %for boldface math
\usepackage{braket}
\usepackage[colorlinks,citecolor=red,urlcolor=blue,bookmarks=false,hypertexnames=true]{hyperref}
${3:%}\usepackage[math-style=TeX, bold-style=TeX]{unicode-math}
${3:%}\setmainfont{EB Garamond}
${3:%}\setmathfont{Garamond-Math.otf}[StylisticSet={6,10}]
${4:%}\usepackage[T1]{fontenc}
${4:%}\usepackage{garamondx}
${4:%}\usepackage[garamondx,cmbraces]{newtxmath}
${4:%}\usepackage{bm} %for boldface math
%\usepackage{anyfontsize}
\newcommand{\diff}{\mathop{}\!\mathrm{d}}
\usepackage[a4paper, scale=0.9]{geometry}
\usepackage{tcolorbox}
\title{${5:Title}}
\author{${6:Author}}
${7:%}\date{}
\begin{document}
\begin{tcolorbox}
\maketitle
\end{tcolorbox}
%\par\noindent\rule[0.5cm]{\textwidth}{1pt}
${0:start_hammering}
\newpage
\begin{thebibliography}{99}
\end{thebibliography}
\end{document}
endsnippet
This fails to work. What I want to do is achieve similar result as that of the simple example I showed above. When my cursor reaches $3
and I start typing : it is only substituted in one instance of $3
and not all the instances. Likewise for $4
as well. To be crystal clear, my goal here is to do the following : if I delete the default text (%
) appearing at the first instance of $3
and all the instances of $3
should be modified accordingly.
Can someone please help me figure out how to correct this?