[Tex/LaTex] load custom .cwl on a per-document basis in TexStudio

texstudio

Say I have document A in which I define a new command, \foo.

I'd like to have \foo{} autocomplete in document A, but document B does not use \foo. Instead, it uses a command \food. I don't want Texstudio to autocomplete to \foo when I'm working in document B.

Is there some way I can have a custom .cwl file load when I am working in document A and a different .cwl when working on document B?

I know I can go and uncheck .cwl files in the autocomplete config, but I'd like to automate this if possible so I don't have to remember to check/uncheck every time I work on something new.

Best Answer

Reposted the comments above as an answer:

TeXstudio automatically detects \newcommand definitions and adds these commands to the completer. If you don't need the cwl file to specify special behavior of the command, you can simply leave out cwl files at all. But if you really need cwl files, there is currently no way to automatically load specific ones. We'll consider this in the further development.

Meanwhile if you don't want to switch the cwls manually you could load both and add * to the less often used command. Then it will only show up in the "all" tab of the completer. (Ok it's a crude workaround, but at least both commands will be known and only one will appear in the "typical" completer tab.)

Related Question