Skip to content

feat: visual promote/demote headings#1117

Open
celsobenedetti wants to merge 2 commits intonvim-orgmode:masterfrom
celsobenedetti:feat/visual-promote-demote
Open

feat: visual promote/demote headings#1117
celsobenedetti wants to merge 2 commits intonvim-orgmode:masterfrom
celsobenedetti:feat/visual-promote-demote

Conversation

@celsobenedetti
Copy link
Contributor

@celsobenedetti celsobenedetti commented Mar 17, 2026

Summary

This implements visual mappings for > and < to demote/promote headings.

It uses a "dumb" string parsing approach:

  1. If current selection does not include headline, fallback to vim default behavior.
  2. else, interate over each line in visual selection
  3. check if line is heading with ^%*+
  4. if yes promote/demote heading
  5. else, leave unchanged

Related Issues

Closes #860

Changes

  • Added OrgMappings:do_promote_visual and OrgMappings:do_demote_visual
  • Added visual mappings for > and <
output.mp4

caveat: the demo above is done with org_adapt_indentation = false. The indentation is virtual, with :Org indent_mode<CR>. Only heading lines are modified. If we want to indent all lines in selection this will require some extra logic, based on the select indent_mode. I'm incline to KISS, and only modify the heading lines.

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

@celsobenedetti celsobenedetti force-pushed the feat/visual-promote-demote branch from 94c7fab to f9b58b8 Compare March 17, 2026 01:33
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.

Support org_do_promote and org_do_demote in visual mode

1 participant