I'm writing Latex, and recently found some of the following snippets:
snippet // "Fraction" iA
\\frac{$1}{$2}$0
endsnippet
snippet '((\d+)|(\d*)(\\)?([A-Za-z]+)((\^|_)(\{\d+\}|\d))*)/' "Fraction" wrA
\\frac{`!p snip.rv = match.group(1)`}{$1}$0
endsnippet
priority 1000
snippet '^.*\)/' "() Fraction" 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
snippet / "Fraction" iA
\\frac{${VISUAL}}{$1}$0
endsnippet
For my logic class, we use the notation v(u/y) to denote something, but I don't want the u/y to actually become a fraction. Usually what I do is comment out these snippets for the time being, and for my probability class, when I actually do want fractions, uncomment them.
Clearly this is a travesty of the utility of Ultisnips. How can I make my life easier by, for example, just issuing a simple ex command to comment these things out (without commenting out the rest of my tex.snippets)? Is there any other way to make my life easier?
If the format is always like the examples, you could use tpope/commentary to do
:g/Fraction/norm gcap
Otherwise you’ll need to find the appropriate range in the file and do
:[range]s/^/"/
Is it possible to use v(u|y)
instead in your logic class, avoiding the snippets altogether? Alternatively, disable automatic firing of the snippets when working on those files (I thought Ultisnips required a trigger anyway.)