# Customize cursor position in TeXnicCenter autocompletion

For example, the following in math.xml makes possible autocompletion for the equation envirionment

<lxEnvironment name="equation"
parameters="1"
desc="Math environment"
icon="math.bmp"
index="10"
expafter="}&#xA;&#xA;\label{eq:}&#xA;"
expbefore="\begin{"/>


so that when I type equ and hit Ctrl+Space, the following is autocompleted

$$\label{eq:}$$


I want to ensure that after the autocompletion, the cursor stops at a given place, say, after eq:. Right now, it stops at the empty line. I was not able to change the behavior by playing with the parameters in the Xml code. I am using TeXnicCenter 2.02.

I vaguely remember it is possible to achieve this effect in TeXnicCenter 1, forgot how to do it.

Well, the general rule for the syntax for lxEnvironment seems to be the following:

1. the content of variable expbefore is printed (results in \begin{)
2. the name of the environment, here equation, is added. Now we have: \begin{equation
3. the content of variable expafter is added, with &#xA; changed to a newline.
4. At last it seems that the cursor is set to the (first?) blank line or more simple after the closing } of .

The given complete code:

    <lxEnvironment name="equation"
parameters="1"
desc="Math environment"
icon="math.bmp"
index="10"
expafter="}&#xA;&#xA;\label{eq:}&#xA;"
expbefore="\begin{"/>


You can test this by changing the content of expbefore for example to expbefore="&#xA;&#xA;\label{eq:" and expafter to expafter="}&#xA;". Then you get equation inserted after ...eg: and the cursor stays at the beginning of the blank line. I think that is hardcoded in the code of TeXnicCenter. To get that changed please contact the support of TeXnicCenter, located on the homepage of TeXnicCenter

For an easy testing you can for example create an file mycommand.xls like this:

<?xml version="1.0" encoding="ISO-8859-1" standalone="no"?>
<lxCollection version="1" xmlns:txclxp="http://schemas.ToolsCenter.org/TeXnicCenter/LaTeXCommands.xsd">
path=""
desc="My commands"
>
<lxEnvironment name="testerle"
parameters="0"
desc="Math environment"
icon="math.bmp"
index="10"
expafter="}&#xA;"
expbefore="&#xA;&#xA;\label{eq:"/>
</lxPackage>
</lxCollection>
<!-- $Id$ -->
<!--
$Log: username.xml,v$
no message

-->


and copy it to the system path where Windows installed your TeXnicCenter, for example C:\Program Files\TeXnicCenter\Packages (64bit version).

After a restart of TeXnicCenter (close all TeXnicCenter windows, open then a new one) you can test the now loaded new environment testerle (to avoid problems with the real needed and installed equation) ...