Sublime Forum

Snippets running Commands

#1

Hello!

I am using the latexing package here: latexing.com/

They have a snippet that when I type sec, the following is inserted:

[code]\section{CURSOR HERE} % (fold)
\label{sec:CURSOR_HERE}

% section CURSOR_HERE (end)[/code]

Everywhere it says cursor here is highlighted at once and changed as I type. The interesting part is that under section I type “my title” and the other two places get “my_title” How does the snippet automatically replace spaces with an underscore? I thought it wasnt possible for snippets to run custom commands?

Thanks!

0 Likes

#2

You can use regexp substitution in snippets:
docs.sublimetext.info/en/latest/ … stitutions

However, your example doesn’t look like a valid snippet, a plugin probably do the works here.

0 Likes