# Autocomplete & slash commands

Package-aware LaTeX commands, citation details, file paths, math shortcuts, and reusable snippets.

The editor completes three things as you type: LaTeX commands, cross-references, and citations. Add the `/` slash menu for structure, and most documents can be written without typing boilerplate.

Suggestions appear automatically while typing; Ctrl+Space summons them anywhere. Accept with Tab or Enter.

## Command completion

Type a backslash and keep going: `\sec…` offers `\section`, and `\fra…` offers `\frac`. Completion draws on a broad LaTeX command catalog and the packages used by your project. It also includes custom commands and environments from your source.

Completions insert as snippets with tab-stops: accept `\frac` and you get `\frac{│}{}` with the cursor in the numerator; Tab hops to the denominator. Environment completions like `\itemize`, `\enumerate`, `\equation`, and `\align` insert the whole `\begin…\end` block with the cursor inside.

## Reference completion

Inside `\ref{`, `\eqref{`, `\pageref{`, `\autoref{`, `\cref{`, or `\Cref{`, the menu lists every `\label{}` defined in your document. No more scrolling up to remember whether you called it `fig:arch` or `fig:architecture`.

## Citation completion

Inside `\cite{` and its variants (`\citep`, `\citet`, `\citeauthor`, `\citeyear`, `\parencite`, `\textcite`), the menu lists the citation keys from your project's `.bib` files, which are parsed automatically when the project opens.

If the paper isn't in your `.bib` yet, that's what [citation lookup](/docs/citations/) is for: paste a DOI or title and Oleafly adds the entry and the `\cite` in one step.

## Math and structure

Type `$`, `\(`, or `\[` to insert its closing delimiter. When the cursor reaches an inserted closing `$`, type `$` again to move past it. Brackets pair inside inline math, and an empty `$$` pair becomes display math when you press Enter between the delimiters.

Accepting a list environment inserts its first `\item`. Press Enter at the end of an item to continue the list, including a description label or the indentation of a nested list. Press Shift+Enter for a plain newline; leave the new item empty and press Enter again to finish the list.

If you type an unclosed `\begin{...}` yourself, Enter adds the matching `\end{...}`. Use **⌘⌥.** (Ctrl+Alt+.) to close the innermost open environment, or ⌘⌥E (Ctrl+Alt+E) to wrap a selection in an environment. Inside math, type `@` to browse Greek letters and other symbols.

Reference suggestions include the compiled number when it is available from a successful build. Citation suggestions help identify the paper behind a key.

## Control what closes automatically

Open **Settings → Appearance → Editor** when you want less or more automatic typing:

- **Auto-complete** shows suggestions while you type. Ctrl+Space still opens them when this is off.
- **Auto-close brackets** inserts matching brackets and parentheses.
- **Auto-close math** pairs `$`, `\(`, and `\[` with the matching delimiter.
- **Auto-close environments** inserts the matching `\end{...}` when you press Enter after `\begin{...}`.

Turn off only the helper that conflicts with the way you write. Manual completion, environment closing, and wrapping shortcuts remain available.

## The slash menu

Type `/` anywhere and an insert menu opens, filtering as you type:

| Command | Inserts |
|---|---|
| `/section`, `/subsection` | Sectioning commands |
| `/itemize` | Bulleted list |
| `/enumerate` | Numbered list |
| `/item` | A list item |
| `/equation` | Display equation environment |
| `/align` | Aligned multi-line equations |
| `/frac` | A fraction |
| `/figure` | A complete figure float with `\includegraphics` and `\caption` |
| `/table` | A table float with a starter `tabular` |
| `/bold`, `/italic` | `\textbf{}`, `\textit{}` |
| `/label` | `\label{}` |
| `/usepackage` | `\usepackage{}` |

Everything inserts as a snippet with tab-stops, so Tab walks you through the blanks (caption, then label, then onward).

## Good to know

- **Tab does double duty**: it accepts an open suggestion, otherwise it indents.
- Completion menus close when you click elsewhere; Esc dismisses them explicitly.
- Project file paths complete inside supported commands such as `\input{}` and `\includegraphics{}`.
