TeXiFy-IDEA documentation Help

Code completion

TeXiFy automatically completes many structures as you type. Some examples are:

  • Automatic insertion of \end when typing \begin for environments

  • On typing \[ automatic insertion of \], after Enter also with correct indentation

  • Automatic insertion of braces of required parameters

  • Typing } at closing brace skips over it, same for $..$

Some of this basic code completion can be disabled in Settings | Languages & Frameworks | TeXiFy.

See the IntelliJ documentation about Code Completion.

TeXiFy supports autocomplete of labels, all commands from installed LaTeX packages, user defined commands, and (user defined) environments.

This includes for example commands you defined with the xparse package.

xparse-autocomplete

Autocompletion for all words

If you are looking for a 'dumb' autocompletion mode to autocomplete on any word in the file/project, you can use Hippie completion: https://www.jetbrains.com/go/guide/tips/cyclic-expand-word/ and https://www.jetbrains.com/help/idea/auto-completing-code.html#hippie_completion

GitHub Copilot

GitHub Copilot is machine-learning based autocompletion provided as a separate plugin. It can give larger suggestions than TeXiFy will do, but in some cases the completion conflicts with or confuses TeXiFy, so use with care.

Copilot
Copilot

Autocompletion of required parameters

Since b0.6.9

When invoking autocomplete on a command or environment that takes required parameters, TeXiFy will insert a brace pair for each parameter. The caret is placed in the first pair, and you can use Tab to skip to the next pair. Since optional parameters are, well, optional, both the command with and without the optional parameters appear in the autocomplete list. If you always select the version with optional parameters, after a couple of times IntelliJ will remember your choice and show it first (so above the version without optional parameters).

required-parameters-autocomplete
required-parameters-environments

Autocompletion of commands from installed LaTeX packages.

Since b0.7.4

TeXiFy will look in your LaTeX installation for installed LaTeX packages, and then figures out what commands those packages provide to put those in the autocompletion. The indexing of all packages can take significant time (up to one minute for TeX Live full with thousands of packages) so this is persistent between restarts. If you want to reset the index, use File | Invalidate Caches / Restart.

Often, the extracted information includes the command parameters and some documentation about the command (see LaTeX documentation). However, this relies on package authors respecting the LaTeX conventions (using the doc package). If you find something incorrect, please let us know and then we can determine whether something needs to be improved in the LaTeX package or in TeXiFy.

In the case of TeX Live, TeXiFy will currently not suggest commands from all packages you have installed, because a lot of users have TeX Live full installed, so you would get completion for all commands in any LaTeX package ever written! This would flood the completion with many commands that are very rarely used. Therefore, TeXiFy will only suggest commands from packages that you have already included somewhere in your project, directly or indirectly via other packages.

command-autocomplete1
command-autocomplete2

MiKTeX admin install

With MiKTeX, TeXiFy needs to extract zipped files in order to obtain source files of LaTeX packages. If you installed MiKTeX as admin, this will not be possible. The MiKTeX installer clearly warns about this:

miktex-admin

On Linux the warning is less clear though:

miktex-linux

Inserting \item in itemize environments

When writing in an itemize-like environment, pressing Enter will automatically insert an \item on the next line. This allows for easy writing of lists.

If you are writing an item in the list but you do want a linebreak, for example to start a new sentence, use Shift + Enter.

If your cursor is in the middle of a line and you want to split it, but without inserting an \item in the middle, use Ctrl + Enter.

An example which shows the use of Enter at the end of a line, Enter at the middle of a line, Shift + Enter and Ctrl + Enter (in that order):

itemize-enter

Note that for even quicker insertion of an itemize you can use live templates (itm for itemize by default) as described in Live templates.

Brace matching

TeXiFy matches braces, inline math and more. If you type the first one, the second one will be automatically inserted. You can disable this in File | Settings | Editor | General | Smart Keys | Insert paired brackets.

If you then continue typing, you can exit the brace pair by typing the closing brace or dollar sign, or you can use tab if you have File | Settings | Editor | General | Smart Keys | "Jump outside closing bracket with Tab when typing" enabled.

brace-matching
brace-matching2

Live templates

Using live templates, you can quickly insert a predefined piece of text by typing just a few characters of a certain key. You can denote places to which the cursor skips when you press Tab after inserting the live template.

To use a live template, type (a part of) the key, for example fig, hit enter when the live template is suggested in the autocomplete, type things and use Tab to skip to the next place to type information.

live-templates

Currently implemented by default are live templates for:

  • figures, tables, itemize, enumerate, and in math for summations and integrals;

  • sectioning with automatic label (triggered with \partl, \chapl, \secl, etc.), since b0.7.3.

You can find these live templates, as well as add your own, under File | Settings | Editor | Live Templates | LaTeX. Since b0.7.4: the default live templates are disabled in verbatim contexts.

live-template-settings

For more information, see https://www.jetbrains.com/help/idea/creating-and-editing-live-templates.html

Postfix code completion

Since b0.6.10

Using postfix templates, you can quickly add some code to the text you previously typed. You can apply a postfix template to the previous word (or command) by typing a . directly after the word and then typing the key of the template.

text-postfix

Currently available are commands for text decoration, and some commonly used math mode accents.

math-postfix

A list of available templates is in File | Settings | Editor | General | Postfix Completion, where you can edit the key of a template. You can also add your own templates. For more advanced editing of postfix templates, have a look at the Custom Postfix Templates plugin. The plugin allows the creation of custom postfix templates for a number of languages, including LaTeX.

See also https://www.jetbrains.com/help/idea/auto-completing-code.html#postfix_completion.

Smart quote substitution

The csquotes package provides the \enquote command. TeXiFy can automatically insert the command if you type regular quotes, see Global Settings.

Last modified: 21 November 2024