Skip to content

[UX] Align content with heading indentation level the fist time you use org_do_promote or org_do_demote #859

Closed
@lyz-code

Description

@lyz-code

Describe the bug

Sometimes I find myself moving heading content between headlines by cutting and pasting. As the indentation levels are different I have to use >> and << to adjust the indentation to match the expected.

If I'm moving the content between sections with an even number of heading levels it's "kind of fine" as it's coherent (for example from * Heading to *** Heading), as the action adds or removes two spaces. The things get worse if you move it an odd number, then you are always left with one space too short or one space too much, so you need to remove it (xjxjxjxj...) or add it (i <esc>j.j.j. ...).

It would be nice if the first time you use org_do_promote or org_do_demote it adjusted the content to the heading indentation.

Steps to reproduce

If we start with this file:

* Heading 1
  - Line 1
********** SubHeading 1

And we cut and paste the content

* Heading 1
********** SubHeading 1
  - Line 1 <-- cursor here

To adjust the content to the desired level we need to press >> 4 times

But that doesn't yet adjust the level fine as we promoted an odd number of headings

* Heading 1
********** SubHeading 1
          - Line 1<-- cursor here

So we need to add a whitespace 0i

* Heading 1
********** SubHeading 1
           - Line 1

Expected behavior

Instead from the point of having the text pasted

* Heading 1
********** SubHeading 1
  - Line 1 <-- cursor here

I'd like to press >> once to get:

* Heading 1
********** SubHeading 1
           - Line 1

Emacs functionality

No response

Minimal init.lua

local tmp_dir = vim.env.TMPDIR or vim.env.TMP or vim.env.TEMP or "/tmp"
local nvim_root = tmp_dir .. "/nvim_orgmode"
local lazy_root = nvim_root .. "/lazy"
local lazypath = lazy_root .. "/lazy.nvim"

for _, name in ipairs({ "config", "data", "state", "cache" }) do
	vim.env[("XDG_%s_HOME"):format(name:upper())] = nvim_root .. "/" .. name
end

-- Install lazy.nvim if not already installed
if not vim.loop.fs_stat(lazypath) then
	vim.fn.system({
		"git",
		"clone",
		"--filter=blob:none",
		"https://github.com/folke/lazy.nvim.git",
		"--branch=stable", -- latest stable release
		lazypath,
	})
end
vim.opt.rtp:prepend(lazypath)

require("lazy").setup({
	{
		"nvim-orgmode/orgmode",
		event = "VeryLazy",
		ft = { "org" },
		config = function()
			require("orgmode").setup({
				org_agenda_files = {
					"*.org",
				},
				mappings = {
					capture = {
						org_capture_finalize = "<c-s>",
					},
				},
			})
		end,
	},
}, {
	root = lazy_root,
	lockfile = nvim_root .. "/lazy.json",
	install = {
		missing = false,
	},
})

require("lazy").sync({
	wait = true,
	show = false,
})

Screenshots and recordings

No response

OS / Distro

linux

Neovim version/commit

0.10.0

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions