Skip to content

feat: add a bullet when <cr> splits a bullet line - #172

Open
Eotel wants to merge 2 commits into
bullets-vim:masterfrom
Eotel:feat/add-bullet-on-split
Open

Eotel wants to merge 2 commits into
bullets-vim:masterfrom
Eotel:feat/add-bullet-on-split

Conversation

@Eotel

@Eotel Eotel commented Dec 3, 2026

Copy link
Copy Markdown

Closes #139

Summary

Adds g:bullets_add_bullet_on_split (default 0). When it is 1, pressing <cr> in the middle of a bullet moves the text after the cursor into a new bullet instead of a plain line.

" - first |second    (| is the cursor)

" g:bullets_add_bullet_on_split = 0 (default, unchanged)
" - first
" |second

" g:bullets_add_bullet_on_split = 1
" - first
" - |second
 s:insert_new_bullet()
+  if insert mode, not at EOL and the option is on
+    keep the text after the cursor, cut the line at the cursor
   find the bullet of the current line
-  if bullet and (normal mode or at EOL)
+  if bullet and (normal mode or splitting or at EOL)
     add the next bullet (numbering, checkbox, colon indent, renumber as before)
+    append the kept text to it and put the cursor before that text
+  if splitting and no bullet was added
+    restore the line and send <cr> as before

Whitespace around the split point is trimmed. An empty bullet (cursor right after the marker) is not deleted while splitting; the line is split as before.

The second commit removes a trailing space in README.md that makes dprint check fail on master (81570b9), so the Check Formatting job can pass.

Evidence

  • Before: against plugin/bullets.vim on master, the new specs moves the text after the cursor into a new bullet and moves the text after the cursor into the next numeric bullet failed, and splits a line without a bullet as usual passed.
  • After: all 9 spec files pass with Neovim 0.12.6 and plenary.nvim (the same nvim --headless ... plenary.busted command as mise run test), including the existing splits the line and does not add a bullet spec with the default 0. dprint check passes.

Also checked by hand with the option on:

- [x] foo |bar   ->  - [x] foo / - [ ] |bar
- foo: |bar      ->  - foo: / (demoted bullet) |bar
plain foo |bar   ->  plain foo  / |bar      (unchanged)
- foo |bar <cr><Esc>u  ->  - foo bar        (one undo step)

Merge Danger

Door: two-way

The behavior only changes when the option is set to 1.

Blast Radius: small

s:insert_new_bullet() is shared by <cr> and normal-mode o; the new branch only runs in insert mode when the cursor is not at the end of the line.

Eotel added 2 commits December 3, 2026 13:25
Pressing <cr> in the middle of a bullet splits the line without a bullet,
so the text after the cursor loses its bullet. With the new
g:bullets_add_bullet_on_split option, the text before the cursor is
parsed for the bullet and the text after the cursor becomes the text of
the next bullet, with numbering, checkbox and indent handled the same way
as at the end of a line. When no bullet is added, the line is restored
and split as before.

The option defaults to 0 so the current behavior does not change.

Closes bullets-vim#139
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.

[Feature Request] Add bullet on line split

1 participant