Skip to content

Yank the block under the cursor with gy - #14

Merged
Moler1995 merged 2 commits into
mainfrom
feat/yank-block-key
Oct 30, 2026
Merged

Moler1995 merged 2 commits into
mainfrom
feat/yank-block-key

Conversation

@Moler1995

Copy link
Copy Markdown
Owner

What

gy copies the block under the cursor, from R and from S: a fenced code block of any language gives the lines between its fences, a GFM table its own source lines, an image its ![...](...) reference characterwise. The text goes into the unnamed and 0 registers, the cursor stays put, and no engine process is spawned. Off a copyable block — a paragraph, a heading, a list item, an indented code block — the key goes back to Vim untouched.

preview.lua gains find_code_fence beside find_fence on one shared scan, so <CR> keeps previewing only mermaid fences.

Verification

  • MDRN_REPO=$PWD nvim --headless -l tests/headless/run.lua — 1598 checks, 0 failed (new section 8.6: 26 checks)
  • nvim -l tests/interactive/run.lua — 83 checks, 0 failed
  • cargo fmt -p md-render -- --check, cargo clippy -p md-render --all-targets --locked -- -D warnings, cargo test --workspace --locked — clean
  • bash tools/check-readme.sh, openspec validate --all --no-interactive — clean

OpenSpec change add-yank-block-key is archived in this branch and its requirement is synced into openspec/specs/nvim/render-mode/spec.md.

🤖 Generated with Claude Code

yhqian and others added 2 commits October 30, 2026 17:46
A reader who has found the code fence, the table or the image they want
had to leave R for S and yank it by hand. `gy` now takes that block from
either state: a fence contributes the lines between its fences whatever
its language, mermaid included, a table its own source lines with the
pipes, an image its `![...](...)` reference characterwise — into the
unnamed register and `0`, linewise where the block is linewise. Off all
of them the key goes back to Vim untouched, and it never spawns the
engine.

`preview.lua` grows `find_code_fence` beside `find_fence`, both on one
shared scan with a predicate deciding which fences count, so `<CR>` still
previews only mermaid fences.

Co-Authored-By: Claude Code <noreply@anthropic.com>
The block under the cursor can now be taken from either state with `gy`:
a code fence gives the lines between its fences, a table its source
lines, an image its reference.

Co-Authored-By: Claude Code <noreply@anthropic.com>
@Moler1995
Moler1995 merged commit 7d33c30 into main Oct 30, 2026
9 checks passed
@Moler1995
Moler1995 deleted the feat/yank-block-key branch October 30, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant