Pasting bullet lists leads to ever-increasing indentation

I’m struggling with pasting content formatted as an HTML unordered list from a browser into a Kakoune buffer. Each list item line seems to be indented one more level than the previous list item. I’m running on Pop!_OS and using Firefox as my browser. I’m running Kakoune v2022.10.31-86-g3150e9b3.


I copy these items onto the system clipboard:

(This is Markdown, but I render it as HTML first, so I’m copying from a browser onto the system clipboard.)

# Heading

Some explanatory text

Some more explanatory text

- List item 1
- List item 2
- List item 3

A third paragraph of explanatory text

- List item 4
- List item 5

When I copy and paste this into a Kakoune buffer, I get this:


Some explanatory text

Some more explanatory text

    List item 1
        List item 2
            List item 3

            A third paragraph of explanatory text

                List item 4
                    List item 5

Notice that the list items are indent ever-more-deeply, even though the raw paragraph (<p>) is in line with the last list item in the preceding list.

I infer this is one of the following, but I need help figuring out which one:

  • configuration setting I’m missing and need
  • configuration setting that I have wrong
  • interfering/overzealous plugin

Have you seen this before? What was the problem for you?

Do you have an idea what would cause this? How would I check?


This is because of auto-indent hooks that are part of most filetype support scripts. Proposed fix is Implement bracketed paste by krobelus · Pull Request #4824 · mawww/kakoune · GitHub
One workaround is to press backslash before entering insert mode, to disable hooks for the duration of the insert session.
Another workaround is to use set global disabled_hooks markdown-indent but that will disable the feature entirely, it’s often useful.
Another workaround is to use !wl-paste instead of using the terminal paste shortcut


Thank you for this. I had no idea about “no-hooks” and would never have thought to go looking for it. That seems very useful in general.

I’m not so sure… I also have a problem when I paste a list that all the items after the first one in the list are double-bulleted. I get this:

- Item 1
- - Item 2
- - Item 3
- - Item 4

when I’m expecting a flat list. Something about markdown-indent just doesn’t seem to work, for some meaning of “work”.

I’m not using Wayland, so I imagine I could use copyq’s paste command, although when I try to do that (!copyq paste), kakoune seems to paste the content in normal mode rather than insert mode. This means that insert doesn’t happen until the pasted content happens to contain an i, a, c, or o. I looked through the documentation for a way to just insert the output, but couldn’t find it. Do you happen to know off the top of your head how I can use this workaround?

And, of course, as soon as I publish the question, I find the answer: i<Alt+;>!copyq paste seems to do what I want, even if it’s a bit clunky to switch to insert mode only to switch back to normal mode to execute a single command. Could one do better?

Thank you for the ideas; they really helped.

Here is what I used before I had bracketed paste support. The behavior is almost equivalent (I think the only diff is that these commands also select what’s pasted in an i session, not only the a session).

define-command -override my-clipboard-paste %{
	execute-keys %{!copy paste<ret>} # xclip -o / pbpaste / wl-paste etc.

map global insert <c-v> <esc><semicolon>:my-clipboard-paste<ret>a
map global normal <c-v> :my-clipboard-paste<ret>

define-command -override my-clipboard-paste-prompt %{
	evaluate-commands -verbatim set-register t %sh{copy paste}
map global prompt <c-v> %{<a-semicolon>:my-clipboard-paste-prompt<ret><c-r>t}

# alternative bindings for raw-insert
map global insert <c-q> <c-v>
map global prompt <c-q> <c-v>
1 Like

Thanks again. Even seeing another configuration example helps me understand a little better how to do things myself in the future.