# `Minga.Editing`
[🔗](https://github.com/jsmestad/minga/blob/main/lib/minga/editing.ex#L1)

Editing domain facade.

Cursor motions, text operations, search, bracket matching, comment
toggling, formatting, and scroll state. This module is the only
valid entry point from outside the domain.

External callers use this facade for behavior. Struct types
(`Minga.Editing.Completion.t()`, `Minga.Editing.Search.Match.t()`,
`Minga.Editing.Scroll.t()`) may be referenced directly in `@spec`
annotations per AGENTS.md type-crossing rules. Protocols
(`Minga.Editing.Text.Readable`) and behaviours
(`Minga.Editing.Model`) are also part of the public API.

# `active_model`

```elixir
@spec active_model() :: module()
```

Returns the active editing model module from global config. Prefer active_model/1 when state is available.

# `active_model`

```elixir
@spec active_model(map()) :: module()
```

Returns the active editing model module from editor state.

# `apply_save_transforms`

Apply save-time transforms (trim trailing whitespace, final newline).

# `backspace_with_pairs`

Backspace, removing the matching bracket when the cursor is between a pair.

# `binding_state`

```elixir
@spec binding_state(map()) :: atom()
```

Returns the keymap binding state for scope trie resolution.

This is the discriminator that `Scope.resolve_key/3` uses to select
which trie of bindings to look up. CUA always returns `:cua`. Vim
returns the current mode mapped to the scope-relevant subset
(`:normal`, `:insert`, `:input_normal`).

Use this instead of manually checking `cua_active?` and branching
on the editing model in input handlers.

# `change`

# `comment_prefix`

Resolve comment prefix with nil fallback.

# `comment_prefix_at`

Resolve comment prefix accounting for injection ranges.

# `compute_comment_edits`

Compute comment toggle edits for the given lines (pure, no Buffer I/O).

# `cursor_shape`

```elixir
@spec cursor_shape(map()) :: :beam | :block | :underline
```

What cursor shape should the frontend render?

# `delete`

# `document_end`

# `document_start`

# `find_char_backward`

# `find_char_forward`

# `first_non_blank`

# `format`

Format content using a formatter command string.

# `in_leader?`

```elixir
@spec in_leader?(map()) :: boolean()
```

Is a leader key sequence in progress?

# `insert_with_pairs`

Insert a character, auto-inserting the matching bracket when appropriate.

# `inserting?`

```elixir
@spec inserting?(map()) :: boolean()
```

Is the user currently inserting text?

# `key_sequence_pending?`

```elixir
@spec key_sequence_pending?(map()) :: boolean()
```

Is a multi-key sequence in progress (leader key, operator-pending, etc.)?

# `line_end`

# `line_start`

# `macro_recording_status`

```elixir
@spec macro_recording_status(map()) :: {true, String.t()} | false
```

Is a macro currently being recorded? Returns {true, register} or false.

# `match_bracket`

# `minibuffer_mode?`

```elixir
@spec minibuffer_mode?(map()) :: boolean()
```

Is the editor in a minibuffer-occupying mode (command line, search, eval)?

# `mode`

```elixir
@spec mode(map()) :: atom()
```

Current editing mode atom (e.g., :normal, :insert, :visual, :cua).

# `new_scroll`

Creates a new scroll state with default values.

# `paragraph_backward`

# `paragraph_forward`

# `pin_to_bottom`

Pin scroll to the bottom of content.

# `resolve_formatter`

Resolve the formatter spec for a filetype and file path.

# `resolve_scroll`

Resolve a scroll target given total content lines and visible height.

# `scroll_down`

Scroll down by the given number of lines.

# `scroll_to_top`

Scroll to the top of content.

# `scroll_up`

Scroll up by the given number of lines.

# `search_all_in_range`

Find all matches for a pattern within a line range.

# `search_next`

Find the next match for a pattern starting from a position.

# `select_around_parens`

# `select_around_quotes`

# `select_around_word`

# `select_inner_parens`

# `select_inner_quotes`

# `select_inner_word`

# `select_structural_around`

# `select_structural_inner`

# `selecting?`

```elixir
@spec selecting?(map()) :: boolean()
```

Does the user have an active selection?

# `set_scroll_offset`

Set the scroll offset directly.

# `status_segment`

```elixir
@spec status_segment(map()) :: String.t()
```

Short mode label for the status bar (e.g., 'NORMAL', 'INSERT', '').

# `substitute`

Substitute all matches in buffer content.

# `substitute_line_preview`

Substitute matches in a single line, returning styled spans for preview.

# `till_char_backward`

# `till_char_forward`

# `visual_line_down`

# `visual_line_end`

# `visual_line_start`

# `visual_line_up`

# `word_backward`

# `word_backward_big`

# `word_end`

# `word_end_big`

# `word_forward`

# `word_forward_big`

# `word_under_cursor`

Returns the word under the cursor, or nil.

# `yank`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
