# Placeholders¶

A very powerful feature of TeXnicCenter are placeholders. They are used on occasions when values or commands need to be specified that will change dynamically during runtime. This feature allows the user a very flexible configuration of TeXnicCenter because command line arguments, DDE-commands or other values do not have to be specified statically, but will be dynamically generated by TeXnicCenter when needed.

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

There a two types of placeholders in TeXnicCenter:

Placeholders for single files
This type of placeholders is often used to define command-line arguments and DDE-commands.
Placeholders for sets of files
This kind of placeholders are used to deal with more than one file at a time.

## Placeholders for single files¶

Placeholders referring to single files are used in such cases, where arguments for command line tools (like LaTeX) and DDE-commands need to be defined.

Placeholders for single files have to begin with a percent sign % followed by up to three characters. The last character specifies which files the placeholder refers to:

m

Current project’s main filename.

c

Current filename, i.e. 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.

w

The file’s relative path starting in project directory, i.e. working directory.

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).

r

The file’s drive letter (followed by colon :).

Instead of p, w, d and m 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 referring to project’s main file¶

The following placeholders are used as a reference to a project’s main file. If the Build ‣ Current File... command is used, these placeholders will be replaced with the equivalents for the current file.

The examples in brackets show how the placeholder will be replaced, if the current project’s main file is C:\My Documents\TxcTest\JustATest.tex.

%pm

Will be replaced by the full path of the current project’s main file, e.g.

C:\My Documents\TxcTest\JustATest.tex
%wm

Will be replaced by the relative path of the current project’s main file, e.g.

JustATest.tex
%dm

Will be replaced by the directory of the current project’s main file, e.g.

C:\My Documents\TxcTest
%nm

Will be replaced by the name of the current project’s main file. The name includes the file extension, e.g.

JustATest.tex
%tm

Will be replaced by the title of the current project’s main file. The title does not include the file extension, e.g.

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, e.g.

C:\My Documents\TxcTest\JustATest

#### Placeholders with slashes instead of backslashes¶

%Pm

Same as %pm but using slashes instead of backslashes, e.g.

C:/My Documents/TxcTest/JustATest.tex
%Dm

Same as %dm but using slashes instead of backslashes, e.g.

C:/My Documents/TxcTest
%Bm

Same as %bm but using slashes instead of backslashes, e.g.

C:/My Documents/TxcTest/JustATest

#### Placeholders for 8.3 path notation¶

%spm

Same as %pm, but using the 8.3 path notation, e.g.

C:\MyDocu~1\TxcTest\JustAT~1.tex
%sdm

Same as %dm, but using the 8.3 path notation, e.g.

C:\MyDocu~1\TxcTest
%snm

Same as %nm, but using the 8.3 path notation, e.g.

JustAT~1.tex
%stm

Same as %tm, but using the 8.3 path notation, e.g.

JustAT~1
%sem

Same as %em, but using the 8.3 path notation, e.g.

tex
%sbm

Same as %sbm, but using the 8.3 path notation, e.g.

C:\MyDocu~1\TxcTest\JustAT~1

#### Placeholders for 8.3 path notation with slashes instead of backslashes¶

%sPm

Same as %spm, but using slashes instead of backslashes, e.g.

C:/MyDocu~1/TxcTest/JustAT~1.tex
%sDm

Same as %sdm, but using slashes instead of backslashes, e.g.

C:/MyDocu~1/TxcTest
%sBm

Same as %sbm, but using slashes instead of backslashes, e.g.

C:/MyDocu~1/TxcTest/JustAT~1

### Placeholders referring to current file¶

The following placeholders are used to reference the current file. The current file is the file opened in the editor, i.e it has the input focus. If no file is open in the editor the placeholders will not be replaced.

The examples in brackets show how the placeholder will be replaced, if the current file is C:\My Documents\TxcTest\SubDir\AnotherTest.tex and the current project’s main file is C:\My Documents\TxcTest\JustATest.tex.

%pc

Will be replaced by the full path of the current file, e.g.

C:\My Documents\TxcTest\SubDir\AnotherTest.tex
%wc

Will be replaced by the relative path of the current file, e.g.

SubDir\AnotherTest.tex
%dc

Will be replaced by the directory of the current file, e.g.

C:\My Documents\TxcTest\SubDir
%nc

Will be replaced by the name of the current file. The name includes the file extension, e.g.

AnotherTest.tex
%tc

Will be replaced by the title of the current file. The title does not include the file extension, e.g.

AnotherTest
%ec

Will be replaced by the extension of the current file, e.g.

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, e.g.

C:\My Documents\TxcTest\SubDir\AnotherTest

#### Placeholders with slashes instead of backslashes¶

%Pc

Same as %pm, but using slashes instead of backslashes, e.g.

C:/My Documents/TxcTest/SubDir/AnotherTest.tex
%Dc

Same as %dm, but using slashes instead of backslashes, e.g.

C:/My Documents/TxcTest/SubDir
%Bc

Same as %bm, but using slashes instead of backslashes, e.g.

C:/My Documents/TxcTest/SubDir/AnotherTest

#### Placeholders for 8.3 path notation¶

%spc

Same as %pm, but using the 8.3 path notation, e.g.

C:\MyDocu~1\TxcTest\SubDir\Anothe~1.tex
%sdc

Same as %dm, but using the 8.3 path notation, e.g.

C:\MyDocu~1\TxcTest\SubDir
%snc

Same as %nm, but using the 8.3 path notation, e.g.

Anothe~1.tex
%stc

Same as %tm, but using the 8.3 path notation, e.g.

Anothe~1
%sec

Same as %em, but using the 8.3 path notation, e.g.

tex
%sbc

Same as %sbm, but using the 8.3 path notation, e.g.

C:\MyDocu~1\TxcTest\SubDir\Anothe~1

#### Placeholders for 8.3 path notation with slashes instead of backslashes¶

%sPc

Same as %spm, but using slashes instead of backslashes, e.g.

C:/MyDocu~1/TxcTest/SubDir/Anothe~1.tex
%sDc

Same as %sdm, but using slashes instead of backslashes, e.g.

C:/MyDocu~1/TxcTest/SubDir
%sBc

Same as %sbm, but using slashes instead of backslashes, e.g.

C:/MyDocu~1/TxcTest/SubDir/Anothe~1

### Placeholders referrening to a selection in the current file¶

%l

Will be replaced with the line number, the cursor is placed in this line in the current file. The first line has the number 1.

%s

Will be replaced with 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¶

%%

Will be replaced by the string %.

\$\$

Will be replaced by the string \$.

## Placeholders for sets of files¶

Placeholders can be used for handling sets of files.

Note

These placeholders will never generate duplicates of a filename.

\$[q][s][f][r]<FILESET>

\$

Starts the placeholder. Use \$\$ to get \$.

q

All filenames will be separately quoted using ".

s

All filenames will be issued in 8.3-format.

f

The forward slash / is used as directory separator.

r

The filenames will be given relative to the working directory of the project.

<FILESET>

One of the following:

TPF

All TeX-files of the project.

BPF

All BibTeX-files of the project.

GPF

All Graphic-files of the project.

TXC

All files generated by TeXnicCenter regarding the project. Currently only the .tcp and .tps files.

COF

All currently opened files in the editor.

APF

All project files. This is the sum of TPF, BPF, GPF and TXC.

AFS

All above filesets together. This is the sum of TPF, BPF, GPF, TXC and COF.

### Examples¶

\$qTPF

Lists all (La)TeX-files reported by the structure parser of TeXnicCenter. File names in quotes and separated by a space, like:

"D:\Temp\test\curvature3d.tex" "D:\Temp\test\definitions\macros.tex" "D:\Temp\test\chaptertwo.tex"

\$fBPF

Lists all BibTeX-files reported by the structure parser of TeXnicCenter. The forward slash is used as directory separator. File names separated by a space, like:

D:/Temp/test/xbib.bib D:/Temp/test/morebibs/morexbib.bib

\$COF

Lists all files, which are currently opened in the editor. File names separated by a space (no quotes!), like:

D:\Temp\test\curvature3d.tex D:\Program Files\texmf\pdftex\latex\config\pdflatex.ini

\$qsrAPF

Lists all files of the project as reported by the structure parser of TeXnicCenter. File names displayed in 8.3-format, path relative to the working directory, file names separated by a space, like:

"curvat~1.tcp" "curvat~1.tps" "curvat~1.tex" "xbib.bib" "morebibs\morexb~1.bib" "defini~1\macros.tex"
"chapte~1.tex"

## Application example¶

A good idea to use placeholders is a tool like the one defined below. This tool will build a ZIP archive of all files of the current project. A compression program (like WinZip or WinRAR) is required. Adjust path and arguments for that program.

• Command: zip.exe
• Arguments: a "%tm.zip" \$qrAPF
• Initial Directory: %dm