Placeholders

A very powerfull feature of TeXnicCenter are the placeholders, which are used in several cases to specify things that can change dynamically during runtime. This allows the user to configure TeXnicCenter very flexible, because command line arguments, DDE-commands or other things like that do not have to be specified statically, but will be generated by TeXnicCenter dynamically when needed.

Placeholders are a kind of variable. The user just specifies the name of the variable and TeXnicCenter sets the variables value dynamically and replaces its name with the current value, when needed.

Naming Conventions for Placeholders

All placeholders are beginning with a percent signt ('%') followed by up to three characters. The last character specifies which files to reference:

m
The current project's main file.
c
The current file - The file opened in the editor that has the input focus.

The character before the last character describes how to reference the specified file:

p
The file's fully qualified path.
d
The file's directory.
n
The file's name (name and extension).
t
The file's title (name without extension).
e
The file's extension.
b
The file's base (fully qualified path without the file extension).

Instead of 'p', 'd' and 'm' you can use the uppercase variants of these characters to get slashes ('/') instead of backslashes ('\') as path separators.

The percent sign ('%') can be followed by an 's'. In this case, the placeholders will be replaced with paths matching the old 8.3 path convention.

To get a percent sign in the resulting string you have to use the placeholder '%%' which will always be replaced by '%'.

Placeholders for referencing the project's main file

The following placeholders are used to reference a project's main file. If you use the 'Build|Current File|...' commands, these placeholders will be replaced by TeXnicCenter with the equivalents for the current file.

The examples given in brackets are showing, with what the given placeholder would be replaced by TeXnicCenter, when the current project's main file would be "C:\My Documents\TxcTest\JustATest.tex"

%pm
Will be replaced by the full path of the current project's main file. ["C:\My Documents\TxcTest\JustATest.tex"]
%dm
Will be replaced by the directory of the current project's main file. ["C:\My Documents\TxcTest"]
%nm
Will be replaced by the name of the current project's main file. The name includes the file extension. ["JustATest.tex"]
%tm
Will be replaced by the title of the current project's main file. The title does not include the file extension. ["JustATest"]
%em
Will be replaced by the extension of the current project's main file. ["tex"]
%bm
Will be replaced by the base of the current project's main file. The base includes the directory followed by the file's title without the file extension. ["C:\My Documents\TxcTest\JustATest"]

Placeholders using Slashes instead of Backslashes

%Pm
Same as '%pm' but using slashes instead of backslashes. ["C:/My Documents/TxcTest/JustATest.tex"]
%Dm
Same as '%dm' but using slashes instead of backslashes. ["C:/My Documents/TxcTest"]
%Bm
Same as '%bm' but using slashes instead of backslashes. ["C:/My Documents/TxcTest/JustATest"]

Placeholders for 8.3 path notation

%spm
Same as '%pm' but using the 8.3 path notation. ["C:\MyDocu~1\TxcTest\JustAT~1.tex"]
%sdm
Same as '%dm' but using the 8.3 path notation. ["C:\MyDocu~1\TxcTest"]
%snm
Same as '%nm' but using the 8.3 path notation. ["JustAT~1.tex"]
%stm
Same as '%tm' but using the 8.3 path notation. ["JustAT~1"]
%sem
Same as '%em' but using the 8.3 path notation. ["tex"]
%sbm
Same as '%sbm' but using the 8.3 path notation. ["C:\MyDocu~1\TxcTest\JustAT~1"]

Placeholders for 8.3 path notation using Slashes instead of Backslashes

%sPm
Same as '%spm' but using slashes instead of backslashes. ["C:/MyDocu~1/TxcTest/JustAT~1.tex"]
%sDm
Same as '%sdm' but using slashes instead of backslashes. ["C:/MyDocu~1/TxcTest"]
%sBm
Same as '%sbm' but using slashes instead of backslashes. ["C:/MyDocu~1/TxcTest/JustAT~1"]

Placeholders for referencing the current file

The following placeholders are used to reference the current file. The current file is the file opened in the editor, that has the input focus. If no file is open in the editor the placeholders wont be replaced.

The examples given in brackets are showing, with what the given placeholder would be replaced by TeXnicCenter, when the current file would be "C:\My Documents\TxcTest\JustATest.tex"

%pc
Will be replaced by the full path of the current file. ["C:\My Documents\TxcTest\JustATest.tex"]
%dc
Will be replaced by the directory of the current file. ["C:\My Documents\TxcTest"]
%nc
Will be replaced by the name of the current file. The name includes the file extension. ["JustATest.tex"]
%tc
Will be replaced by the title of the current file. The title does not include the file extension. ["JustATest"]
%ec
Will be replaced by the extension of the current file. ["tex"]
%bc
Will be replaced by the base of the current file. The base includes the directory followed by the file's title without the file extension. ["C:\My Documents\TxcTest\JustATest"]

Place Holders using Slashes instead of Backslashes

%Pc
Same as '%pm' but using slashes instead of backslashes. ["C:/My Documents/TxcTest/JustATest.tex"]
%Dc
Same as '%dm' but using slashes instead of backslashes. ["C:/My Documents/TxcTest"]
%Bc
Same as '%bm' but using slashes instead of backslashes. ["C:/My Documents/TxcTest/JustATest"]

Placeholders for 8.3 path notation

%spc
Same as '%pm' but using the 8.3 path notation. ["C:\MyDocu~1\TxcTest\JustAT~1.tex"]
%sdc
Same as '%dm' but using the 8.3 path notation. ["C:\MyDocu~1\TxcTest"]
%snc
Same as '%nm' but using the 8.3 path notation. ["JustAT~1.tex"]
%stc
Same as '%tm' but using the 8.3 path notation. ["JustAT~1"]
%sec
Same as '%em' but using the 8.3 path notation. ["tex"]
%sbc
Same as '%sbm' but using the 8.3 path notation. ["C:\MyDocu~1\TxcTest\JustAT~1"]

Placeholders for 8.3 path notation using Slashes instead of Backslashes

%sPc
Same as '%spm' but using slashes instead of backslashes. ["C:/MyDocu~1/TxcTest/JustAT~1.tex"]
%sDc
Same as '%sdm' but using slashes instead of backslashes. ["C:/MyDocu~1/TxcTest"]
%sBc
Same as '%sbm' but using slashes instead of backslashes. ["C:/MyDocu~1/TxcTest/JustAT~1"]

Placeholders referencing the selection in the current file

%l
Will be replaced by the line number, the cursor is placed on in the current file.

The first line has the number 1

%s
Will be replaced by the current selection in the current file. If nothing has been selected this placeholder will be replaced by the word the cursor is currently placed on.

Other Placeholders

The following special placeholders are available:

%%
Will be replaced by the string '%'.