File tree Expand file tree Collapse file tree 4 files changed +61
-4
lines changed
Expand file tree Collapse file tree 4 files changed +61
-4
lines changed Original file line number Diff line number Diff line change @@ -107,10 +107,34 @@ let g:bullets_custom_mappings = [
107107 \ ]
108108```
109109
110- Enable/disable deleting the last empty bullet when hitting ` <cr> ` (insert mode) or ` o ` (normal mode):
110+ Enable/disable deleting or promoting the last empty bullet when hitting ` <cr> ` (insert mode) or ` o ` (normal mode):
111111
112112``` vim
113- let g:bullets_delete_last_bullet_if_empty = 0 " default = 1
113+ " Example (| is cursor):
114+ " - text
115+ " - text
116+ " - |
117+
118+ let g:bullets_delete_last_bullet_if_empty = 1 " default = 1
119+ " - text
120+ " - text
121+ " |
122+
123+ let g:bullets_delete_last_bullet_if_empty = 0
124+ " - text
125+ " - text
126+ " -
127+ " |
128+
129+ let g:bullets_delete_last_bullet_if_empty = 2
130+ " - text
131+ " - text
132+ " - |
133+ "
134+ " again:
135+ " - text
136+ " - text
137+ " |
114138```
115139
116140Line spacing between bullets (1 = no blank lines, 2 = one blank line, etc.):
Original file line number Diff line number Diff line change @@ -148,7 +148,7 @@ To add a leader key to all mappings set the following:
148148 This will set the <space> key as leader to all default mappings.
149149
150150
151- Disabling empty bullet deletion
151+ Empty bullet deletion
152152-------------------------------
153153By default bullets.vim will delete trailing empty bullets when the return key
154154is pressed, just like modern word processors.
@@ -157,6 +157,10 @@ If you would like to turn this feature off add the following to your .vimrc
157157
158158 `let g:bullets_delete_last_bullet_if_empty = 0`
159159
160+ If you would like to promote bullet instead of deleting it, add the following to your .vimrc
161+
162+ `let g:bullets_delete_last_bullet_if_empty = 2`
163+
160164
161165Maintain right padding on bullets
162166---------------------------------
Original file line number Diff line number Diff line change @@ -574,7 +574,11 @@ fun! s:insert_new_bullet()
574574 " We don't want to create a new bullet if the previous one was not used,
575575 " instead we want to delete the empty bullet - like word processors do
576576 if g: bullets_delete_last_bullet_if_empty
577- call setline (l: curr_line_num , ' ' )
577+ if g: bullets_delete_last_bullet_if_empty == 1
578+ call setline (l: curr_line_num , ' ' )
579+ elseif g: bullets_delete_last_bullet_if_empty == 2
580+ call <SID> change_bullet_level (1 , 0 )
581+ endif
578582 let l: send_return = 0
579583 endif
580584 elseif ! (l: bullet .bullet_type == # ' abc' && s: abc2dec (l: bullet .bullet) + 1 > s: abc_max )
Original file line number Diff line number Diff line change 271271 TEXT
272272 end
273273
274+ it 'promote the last bullet when configured to' do
275+ filename = "#{ SecureRandom . hex ( 6 ) } .txt"
276+ write_file ( filename , <<-TEXT )
277+ # Hello there
278+ - this is the first bullet
279+ - this is the second bullet
280+ TEXT
281+
282+ vim . command 'let g:bullets_delete_last_bullet_if_empty = 2'
283+ vim . edit filename
284+ vim . type 'GA'
285+ vim . feedkeys '\<cr>'
286+ vim . feedkeys '\<cr>'
287+ vim . write
288+
289+ file_contents = IO . read ( filename )
290+
291+ expect ( file_contents . strip ) . to eq normalize_string_indent ( <<-TEXT )
292+ # Hello there
293+ - this is the first bullet
294+ - this is the second bullet
295+ -
296+ TEXT
297+ end
298+
274299 it 'does not delete the last bullet when configured not to' do
275300 filename = "#{ SecureRandom . hex ( 6 ) } .txt"
276301 write_file ( filename , <<-TEXT )
You can’t perform that action at this time.
0 commit comments