Skip to content

Create "Auto Indent" action #30

@mkh-user

Description

@mkh-user

Feature Summary

Introduce an "Auto Indent" action that automatically adjusts the indentation of selected lines or the entire document by modes.

Motivation

Manual indentation is error-prone and time-consuming, especially in code-heavy documents or structured formats like YAML, Python, or Markdown. An auto-indent feature improves readability, enforces consistency, and reduces cognitive load during editing. We had this feature before, but it has become Auto Format, so the implementation will be similar.

Proposed Design

  • Add keyboard shortcut for "Auto Indent". (menu item is in Edit > Indention > Auto Indent)
  • If no selection is made, apply to the entire document.
  • If lines are selected, apply only to the selection.
  • Allow configuration of tab size and spaces vs tabs.

Acceptance Criteria

  • Users can trigger "Auto Indent" via shortcut or command palette.
  • Indentation is applied correctly by current mode.
  • No content is lost or corrupted during indentation.
  • Works with both single-line and multi-line selections.
  • Respects user preferences for tab width and indentation style.

Related Issues / Discussions

Nothing

Implementation Notes (Optional)

  • Consider fallback strategies for unknown file types (e.g., consistent leading whitespace).
  • Integrate with undo stack for safe experimentation.

Localization & Accessibility

  • Localize command name and tooltip.
  • Ensure keyboard shortcut is customizable and accessible.

Community Feedback (Optional)

Nothing

Metadata

Metadata

Assignees

Labels

action scriptsOfficial action scripts or action scripts features

Projects

Status

Completed

Relationships

None yet

Development

No branches or pull requests

Issue actions