From 09c9650d9e081408ee1fbc04c341fb36848bc3b8 Mon Sep 17 00:00:00 2001 From: Marco Herrn Date: Tue, 10 Aug 2021 14:56:30 +0200 Subject: [PATCH 1/3] Support plus signs as bullets for checkboxes --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 6027a7f..152e3c4 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -219,7 +219,7 @@ fun! s:match_checkbox_bullet_item(input_text) " match any symbols listed in g:bullets_checkbox_markers as well as the " default ' ', 'x', and 'X' let l:checkbox_bullet_regex = - \ '\v(^(\s*)([-\*] \[([' + \ '\v(^(\s*)([-\*\+] \[([' \ . g:bullets_checkbox_markers \ . ' xX])?\])(\s+))(.*)' let l:matches = matchlist(a:input_text, l:checkbox_bullet_regex) From 7b9daa721e0665a83e126384261d722a4d5e6303 Mon Sep 17 00:00:00 2001 From: Marco Herrn Date: Tue, 10 Aug 2021 15:12:56 +0200 Subject: [PATCH 2/3] Support latin numbers as bullets for checkboxes --- plugin/bullets.vim | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 152e3c4..00279ca 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -219,7 +219,7 @@ fun! s:match_checkbox_bullet_item(input_text) " match any symbols listed in g:bullets_checkbox_markers as well as the " default ' ', 'x', and 'X' let l:checkbox_bullet_regex = - \ '\v(^(\s*)([-\*\+] \[([' + \ '\v(^(\s*)(%([-\*\+]|\d+\.) \[([' \ . g:bullets_checkbox_markers \ . ' xX])?\])(\s+))(.*)' let l:matches = matchlist(a:input_text, l:checkbox_bullet_regex) From 70b9d280d738ab3ba37c74e6f9cd04464f303c71 Mon Sep 17 00:00:00 2001 From: Marco Herrn Date: Wed, 6 Aug 2025 21:59:15 +0200 Subject: [PATCH 3/3] Retain the cursor position Moving the cursor to the end of the line on each promote/demote is very disturbing. It is better to stay on the same character. This works for promoting and demoting as long as the number of characters are not changed. But at the moment fails if the bullet is replaced with another one with a different number of characters. In that case we would have to recalculate the position based on the changed characters. --- plugin/bullets.vim | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/plugin/bullets.vim b/plugin/bullets.vim index 00279ca..7727224 100644 --- a/plugin/bullets.vim +++ b/plugin/bullets.vim @@ -814,19 +814,22 @@ command! RenumberList call renumber_whole_list() " Changing outline level ---------------------------------- {{{ fun! s:change_bullet_level(direction) let l:lnum = line('.') + let l:col = col('.') let l:curr_line = s:parse_bullet(l:lnum, getline(l:lnum)) if a:direction == 1 if l:curr_line != [] && indent(l:lnum) == 0 " Promoting a bullet at the highest level will delete the bullet call setline(l:lnum, l:curr_line[0].text_after_bullet) - execute 'normal! $' + call cursor(line('.'), l:col - len(l:curr_line[0].leading_space) - len(l:curr_line[0].bullet) - len(l:curr_line[0].trailing_space)) return else - execute 'normal! <<$' + execute 'normal! <<' + call cursor(line('.'), l:col - shiftwidth()) endif else - execute 'normal! >>$' + execute 'normal! >>' + call cursor(line('.'), l:col + shiftwidth()) endif if l:curr_line == [] @@ -921,7 +924,6 @@ fun! s:change_bullet_level(direction) " Apply the new bullet call setline(l:lnum, l:next_bullet_str) - execute 'normal! $' return endfun