I would like to configure a snippet using Yasnippet to codify in LaTeX. I would like to emulate the behavior of the usual math mode, but replacing single and double dollars with \(\)
and \[\]
, respectively.
I am new to Emacs. So far, I have been able to write the following code, which emulates the behavior of the single dollar:
# name: inline-math
# key: inline-math
# binding: $
# --
\\\(${1:math}\\\)$0
I used to program my own macros in TeXstudio and was able to achieve my desired behavior by reading the characters surrounding the cursor when I called the macro: if the cursor was in the middle of \(\)
, it would delete the surrounding math mode and write \[\]
instead. I would like to do the same here, but i do not know how to move the cursor/read and delete characters with yasnippet (or even if such thing is possible).