Skip to content

:MdRenderAuto: smoother handling of edits that bypass the i/I/a/A/o/O remap #10

Description

@delphinus

:MdRenderAuto keeps the buffer in render mode while in Normal mode and swaps back to source on InsertEnter. To make this work despite the render buffer being nomodifiable, the implementation remaps i / I / a / A / o / O on the render buffer to (1) swap the window's buffer back to the source, then (2) enter Insert mode at the corresponding position.

This makes the common keystrokes "just work", but anything that doesn't go through one of those six keys silently fails on the read-only render buffer. Concrete examples:

  • Ex commands that mutate the buffer: :s, :!filter, gq
  • Operator-pending sequences such as c{motion}, s, S, r, R, gi, gI
  • Macros that contain editing keys other than i/I/a/A/o/O
  • User mappings or plugin commands that enter Insert mode (snippet expansion, LSP code actions, comment toggling that uses Insert under the hood, etc.)

For users whose editing flow leans on these, Auto mode currently feels brittle: the surface promise is "render in Normal mode" but in practice you have to know which keystrokes are intercepted and which aren't.

Possible directions worth exploring (none committed):

  • Extend the remap set to cover more standard editing entry points.
  • Detect attempted edits via BufModified / CmdlineEnter heuristics and swap as a fallback.
  • At minimum, document the limitation in :help :MdRenderAuto and surface a :echohl WarningMsg when an edit is rejected on the render buffer.

Filed as a follow-up to #5; :MdRenderAuto ships as experimental with this limitation called out in the README and :help.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions