TeXworks autocomplete capability is incomplete, messy and unpredictable. Is there any way to migrate TeXStudio auto-complete data to TeXworks?
[Tex/LaTex] TeXworks auto-complete
auto-completiontexstudiotexworks
auto-completiontexstudiotexworks
TeXworks autocomplete capability is incomplete, messy and unpredictable. Is there any way to migrate TeXStudio auto-complete data to TeXworks?
Best Answer
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.cwlTeXworks 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 fromtw-basic.txt
andtw-latex.txt
show the format: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:xa
or\hskip
. This is the only required part.:=
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:
.cwl
files you wanttw-<name>.txt
%%!TEX encoding = UTF-8 Unicode
line (assuming you save them all as UTF-8)#
by%
to make them commentscompletion
folderAn 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).