3

I am creating my own custom .cwl file for TeXstudio. What command should I put in my .cwl file to get the following completion:

\begin{lemma}
    content...
\end{lemma}

with content... specified as a placeholder?

James
  • 162
  • I have read the TeXstudio manual on completion http://texstudio.sourceforge.net/manual/current/usermanual_en.html#CWLDESCRIPTION and it is still unclear how to add the placeholder content.... – James Mar 27 '20 at 03:51

2 Answers2

3

The .cwl file should look like:

\begin{lemma}%\    %<content...%>%\\end{lemma}

and should be saved in C:\Users\[UserName]\AppData\Roaming\texstudio\completion\user for Windows or /.config/texstudio/completion/user on Linus/macOS. Then go into Options -> Configure TeXstudio -> Completion and tick the box next to your .cwl file name.

Tobi
  • 56,353
James
  • 162
  • sorry for bothering, but I have a similar issue trying to make TeXstudio recognize my own packages in the completion list inside the command \usepackage. Do you have any suggestion? This is my question about completion list of my own packages. – FHZ Sep 30 '20 at 20:48
  • @FHZ - I just spent the last 30min on it but no luck. I tried recreating your problem and got the same results as you. To be honest the TeXStudio completion seems pretty buggy to me. Other people have also complained about this. It appears that the #u classification does not work properly. – James Oct 01 '20 at 05:30
  • Thank you very much, at least now I know it is not a local problem nor a catchy secret method I could not understand from the manual reading. – FHZ Oct 01 '20 at 21:54
-1

A .cwl should be saved in C:\Users\[UserName]\AppData\Roaming\texstudio\completion\user. In this file, to introduce a macro, the following code is enough for an environment:

\begin{foo}#S

and for a macro, the following line can be used:

\foo#S

Although the editor accepts these as valid commands, they do not show in the pop-up dialog. Other files can be included in a main file with the following line:

#include:foo