Skip to content

Instantly share code, notes, and snippets.

@rudvfaden
Created September 16, 2014 19:35
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudvfaden/c68002520962a24cb073 to your computer and use it in GitHub Desktop.
Save rudvfaden/c68002520962a24cb073 to your computer and use it in GitHub Desktop.
Sublime snippet for LaTeX environments with matching and self adjusting comment
<snippet>
<content><![CDATA[
%========== ${1/(.+)/\U\1/g}: ${2:Description} ==========%
\begin{${1:Environment}}
$3
\end{${1:Environment}}
%=============${1/./=/g}=${2/./=/g}============%
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>cenv</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<scope>text.tex.latex</scope>
<!-- Optional: Description to show in the menu -->
<description>Enviroment with comment</description>
</snippet>
@rudvfaden
Copy link
Author

Description

This snippet inserts a LaTeX environment wrapped in a comment where the first part of the comment i automatically filled and capitalized from the environment. The description part must be filled manually.

Example

The snippet is inserted with cenv+tab. When first inserted, the snippet will look like this:

%==========  ENVIRONMENT: Description  ==========%
\begin{Environment}

\end{Environment}
%================================================%

But after filling the Environment placeholder, the snippet will self adjust in with and the first part of the comment is filled and capitalized

%==========  EQUATION: Euler's function  ==========%
\begin{equation}
\phi(q)=\prod_{k=1}\infty(1-q^k)
\end{equation}
%==================================================%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment