SirVer / ultisnips

UltiSnips - The ultimate snippet solution for Vim. Send pull requests to SirVer/ultisnips!
GNU General Public License v3.0
7.56k stars 691 forks source link

Nested placeholder {VISUAL:\\includegraphics\{$2\}} #762

Open kiryph opened 8 years ago

kiryph commented 8 years ago

Consider following latex snippet:

snippet EFG "Figure" b
\begin{figure}[${1:<+htpb+>}]
  \centering
  ${VISUAL:\\includegraphics[$3]\{$2\}}
  \caption{${4:<+caption text+>}}
  \label{fig:${5:<+label+>}}
\end{figure}$0
endsnippet

It should be able to surround via visual mode an already existing line

\includegraphics{myinlinegraphic.eps}

to

\begin{figure}[${1:<+htpb+>}]
  \centering
  \includegraphics{myinlinegraphic.eps}
  \caption{${4:<+caption text+>}}
  \label{fig:${5:<+label+>}}
\end{figure}$0

and it also should expand in normal mode from

EFG

to

\begin{figure}[${1:<+htpb+>}]
  \centering
  \\includegraphics[$3]\{$2\}
  \caption{${4:<+caption text+>}}
  \label{fig:${5:<+label+>}}
\end{figure}$0
endsnippet

Is this possible with UltiSnips? I couldn't find confirmation in the docs under 4.3 or in honza snippets repository

SirVer commented 4 years ago

No, this is not currently possible. The default text for VISUAL markers is not parsed for further tabstops and in fact the layout of the code would make it rather difficult to model this.

I agree that this would be a cool feature, but it will be not easy to implement. I will accept a patch if somebody is interested in working on this.