# Confusing code auto-completion in TeXnicCenter yields double \begin

I have experience in programming Python in NetBeans and using the code hints with Ctrl+Space or Tab is a breeze. Here is my experience with using the code hints in TeXnicCenter:

When I type the following:

\begin{d


I will then get a popup that says:

\begin{document}

\end{document}

At this point I eagerly press Ctrl+Space. But to my dismay, I get the following:

\begin{\begin{document}

\end{document}


Any tips on how to use code hints / code completion in TeXnicCenter?

-
mods: I wanted to add the tag code-completion or code-hint. Kindly add it or a more appropriate one if you deem fit. Thanks! –  Kit Aug 20 '10 at 13:15
Done. code-completion is appropriate, the more general auto-completion could be made an alias. –  Stefan Kottwitz Aug 20 '10 at 13:20
@StefanKottwitz: I just tagged this question with code-completion, but I'm not sure if that's what you were intending for with your previous comment. Which one should be a tag synonym of the other one? –  doncherry Oct 13 '11 at 13:34
@doncherry: a long time ago :-) yes, the tag got lost, perhaps I didn't save it. I think they mean both the same for us. One could be an alias for the other. auto-completion could also mean text completion, so it might be the more general tag and master and code-completion could point to it. Let the more commonly used one win. –  Stefan Kottwitz Oct 13 '11 at 13:49
@StefanKottwitz: Why not start out orderly right from the beginning? I'll retag this question with auto-completion (which I was looking for a few times recently) and try to get myself a Synonymizer badge with code-completion, alright? –  doncherry Oct 13 '11 at 13:53

Start typing only the name of the environment, e.g. docu, press the code-completion shortcut, and TexnicCenter will create it with \begin, and appropriate braces. I've been tripped off by this in the beginning as well, but apparently it's supposed to save more typing.

-

It's a feature. To save typing, TeXnicCenter additionally inserts \begin{ when environments are completed. This may be confusing if you don't know it. With this knowledge, it should be easy to use, as mindcorrosive said.

Though, you could change this behavior if you like. To do this, go to TeXnicCenter directory (C:\Program Files\TeXnicCenter for instance), change to the subdirectory Packages and open the file TeX.xml. It contains these lines:

    <lxEnvironment name="document"
desc="Starts a new document"
expafter="}&#xA;&#xA;\end{document}"
expbefore="\begin{"
/>


If you change the expbeforeline to

        expbefore=""


then \begin{do would be expanded to

\begin{document}

\end{document}


But the feature just to expand do to the complete environment would be replaced. I guess you would keep it the original way, but if you're used to the other kind of code-completion you could adjust TeXnicCenter's behavior like described.

Note, you could add further .xml files in that subfolder to extend the code-completion capabilities.

-
Didn't know that. Thanks for the addition. –  Martin Tapankov Aug 20 '10 at 14:37

FYI, Tino Weinkauf regularly publishes news about TeXnicCenter 2 (currently alpha 3) developments at LaTeX Community. Maybe you could ask him about his plans for this feature and if there's any interesting news, add his answer back here.

-

FYI...the support team for TeXnic Center recently (9/16/2013) came out with a release (2.02) that fixes this issue among others. Now if they could just get the word completion to work for anything, and not just code, things would be perfect.

-

Altering the .xml also allows you to change the text which comes up. This is helpful if you include figures in a different way (such as with the pstool package).

In this case alter the xml exp after field to:

expafter="}%&#xA;\centering%&#xA;\psfragfig[width=0.8\textwidth]{test_chapter/test1_matlabfrag_20130917T1147_W3H1b}%&#xA;\caption{qwe2}%%&#xA;\label{fig:f1}%%&#xA;%&#xA;\end{figure}"

-