# Editing .comm files

`.comm` command files get a language server built from the code_aster command catalog. What it accepts follows the code_aster version you use (see [code_aster versions](/versions)).

Files with the extensions `.comm`, `.com` and `.com0` to `.com9` are code_aster command files. To use another extension, map it to the `code_aster (comm)` language with VS Code's `files.associations` setting.

## Completion

- **Commands** at the top level of the file.
- **Keywords** inside a command call, inserted as `KEY=` (or `KEY=_F()` for factor keywords) with the popup reopening for the value. Keywords already written are not offered again. At the top level of a command, conditional (`BLOC`) keywords are filtered by the values already typed; inside `_F(...)` all of them are offered.
- **Values** for keywords with a fixed list, inserted as `'VALUE', `.
- **Concepts**: after `KEY=`, the concepts defined earlier in the file whose type fits the keyword, with their type and line.
- Completing `DEBUT` inserts the matching `FIN()` with the cursor between them.

Each keyword shows its type, default and whether it is required. Unit numbers, mesh group names and file names are not completed.

Typing `(` after a command opens the completion and the signature. Typing `,`, a space after `,`, `=` or Enter inside a call reopens the completion. Word-based suggestions are turned off for `.comm`, so everything offered comes from the catalog.

## Hover

Hovering shows a card for:

- **a command**: its signature with the returned type, description, required and optional keywords with types and defaults, and the catalog rules;
- **a keyword**: its type, status, allowed values or range, and default;
- **an allowed value** of a keyword;
- **a concept**: the command that produced it and the line ("Assigned by `CMD` at line N"), also for concepts declared with `CO("name")` inside a macro;
- `_F` and plain Python assignments.

Factor keywords show as `KEY=_F(...)` in a command card, hover the keyword itself for its content. Cards are in French or English depending on your system locale. Each card links to the code_aster documentation search for the command.

## Signature help

Typing `(` after a command shows the keywords it takes.

## Diagnostics

The file is checked when it opens and again 200 ms after each change. Problems have the source `code_aster`:

| Code | Severity | What it means |
| --- | --- | --- |
| `unknown-command` | Error | The command is not in the catalog |
| `unknown-kwarg` | Error | The keyword does not exist for this command |
| `value-not-in-into` | Error | The value is not one of the allowed values |
| `required-missing` | Error | A required keyword is missing |
| `rule-violation` | Error | A catalog rule is broken (for example two exclusive keywords) |
| `undefined-variable` | Error | A concept is used but never defined |
| `type-mismatch` | Warning | The concept passed has the wrong type for the keyword |
| `deprecated` | Information | The command is deprecated |

Unknown names come with "did you mean" suggestions (the three closest names).

Limits: keywords inside `_F(...)` are not checked, commands are detected as `[name =] COMMAND(` at the start of a line, and a plain Python variable used as a value can be reported as undefined.

Errors from an actual run are reported separately (see [Running studies](/running#diagnostics-from-a-run)). To check concepts and file units across the whole study, use [Study validation](/validation).

## Quick fixes

Three quick fixes are offered from the light bulb (up to six candidates each, the closest one preferred):

- **Replace with `CANDIDATE`** on an unknown command;
- **Rename to `CANDIDATE`** on an unknown keyword;
- **Replace with `'VALUE'`** on a value that is not allowed.

## Formatting

**Format Document** (`Shift+Alt+F` on Windows, `Ctrl+Shift+I` on Linux, `Shift+Option+F` on macOS) and **Format Selection** format the file with ruff:

```bash
python -m ruff format --config format.quote-style="preserve" --line-length=100 --extension comm:python --stdin-filename <file> -
```

The interpreter is the one of `vs-code-aster.pythonExecutablePath`. Set `vs-code-aster.formatter` to `off` to disable formatting, or to another command that reads the file on stdin and writes the result on stdout (it is split on spaces and run without a shell). Formatter messages go to the `code_aster: Formatter` output channel.

## Comments

`Ctrl+/` (`Cmd+/`) and `Ctrl+Shift+;` toggle `#` line comments.

## Command browser and status bar

The [code_aster sidebar](/sidebar#command-browser) lists the catalog commands by family, with those of the active file first, and links each one to its documentation. The status bar shows the code_aster version in use and how many command families the file uses (see [code_aster versions](/versions)).

## What is not available

Go to definition, find references, rename, the outline view, folding by command and semantic highlighting are not implemented.
