TeXworks autocomplete capability is incomplete, messy and unpredictable. Is there any way to migrate TeXStudio auto-complete data to TeXworks?

  • Could you give an example of where it's inconsistent? The core auto-completion data in TeXworks is derived from that in TeX Shop: they use the same format and as such can be readily edited if you want to. Worth noting that each editor has it's own idea of what is and isn't 'sensible' for auto-completion, so this can be as much what you are used to as anything more fundamental. – Joseph Wright Jun 7 '13 at 7:29
  • @JosephWright please see: tex.stackexchange.com/questions/106361/… – PHPst Jun 7 '13 at 11:04

TeXstudio and TeXworks take a somewhat different approach to auto-complete information, at least in part as the two programs have slightly different aims (TeXstudio is a LaTeX editor, TeXworks is a TeX editor and so has fewer LaTeX-specific parts at least in the core). That said, it certainly would be possible to use the auto-complete information from TeXstudio to augment or replace that in TeXworks.

TeXstudio stores auto-completion information on a package-by-package basis in a series of .cwl files. These are simple plain text files and are available from SourceForge (you have to pick and SVN revision: in the link I'd picked the latest one at time of writing). The information doesn't seem to be saved in plain text format in the release code: presumably it's 'baked in' to the binary/libraries. An example file is array.cwl

# mode: array.sty
# dani/2006-02-18

TeXworks stores the completion data in a series of files called tw-<name>.txt which live inside the TeXworks config tree (system-dependent location is a separate question). Some extracts from tw-basic.txt and tw-latex.txt show the format:

%%!TEX encoding = UTF-8 Unicode

The first line is present in all of the tw-<name>.txt files, and quite possibly required. After that, each line is one auto-completion entry. The format is:

  • Line starts with the (partial) text to match, e.g. xa or \hskip. This is the only required part.
  • A := separates out the 'short text' from the 'completion result', but is not needed if the two are the same
  • #RET# represents a carriage return
  • #INS# represents the place the cursor is left after auto-completion
  • is a marker to allow 'quick' moving of the cursor.

As you'll see, the TeXstudio format is actually less complex than that for TeXworks. As a result, conversion seems to require the following steps:

  • Download the .cwl files you want
  • Rename to tw-<name>.txt
  • Add an initial %%!TEX encoding = UTF-8 Unicode line (assuming you save them all as UTF-8)
  • Remove the first two lines, or at least replace the # by % to make them comments
  • Place the new files in the TeXworks completion folder
  • Restart TeXworks

An aside: the TeXworks auto-complete material is derived from that for TeXShop, I believe more-or-less verbatim. Almost certainly the TeXworks developers would welcome improvements in this area, so it would be worth considering discussing this with them. For example, an interface allowing selection of individual auto-complete files would bring TeXworks very close to TeXstudio in terms of auto-completion (scripting could be used to auto-enable completion files).

| improve this answer | |
  • I've asked about the last part on the TeXworks mailing list. – Joseph Wright Aug 17 '13 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.