File tree Expand file tree Collapse file tree 4 files changed +56
-9
lines changed Expand file tree Collapse file tree 4 files changed +56
-9
lines changed Original file line number Diff line number Diff line change @@ -107,10 +107,24 @@ let g:bullets_custom_mappings = [
107
107
\ ]
108
108
```
109
109
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):
111
111
112
112
``` vim
113
- let g:bullets_delete_last_bullet_if_empty = 0 " default = 1
113
+ let g:bullets_process_last_bullet_if_empty = 0 " default = 1
114
+ " - text
115
+ " - text
116
+ " -
117
+ " -
118
+
119
+ let g:bullets_process_last_bullet_if_empty = 1
120
+ " - text
121
+ " - text
122
+ "
123
+
124
+ let g:bullets_process_last_bullet_if_empty = 2
125
+ " - text
126
+ " - text
127
+ " -
114
128
```
115
129
116
130
Line spacing between bullets (1 = no blank lines, 2 = one blank line, etc.):
Original file line number Diff line number Diff line change @@ -148,14 +148,18 @@ To add a leader key to all mappings set the following:
148
148
This will set the <space> key as leader to all default mappings.
149
149
150
150
151
- Disabling empty bullet deletion
151
+ Empty bullet processing
152
152
-------------------------------
153
153
By default bullets.vim will delete trailing empty bullets when the return key
154
154
is pressed, just like modern word processors.
155
155
156
156
If you would like to turn this feature off add the following to your .vimrc
157
157
158
- `let g:bullets_delete_last_bullet_if_empty = 0`
158
+ `let g:bullets_process_last_bullet_if_empty = 0`
159
+
160
+ If you would like to promote bullet instead of deleting it, add the following to your .vimrc
161
+
162
+ `let g:bullets_process_last_bullet_if_empty = 2`
159
163
160
164
161
165
Maintain right padding on bullets
Original file line number Diff line number Diff line change @@ -44,8 +44,8 @@ if !exists('g:bullets_custom_mappings')
44
44
let g: bullets_custom_mappings = []
45
45
endif
46
46
47
- if ! exists (' g:bullets_delete_last_bullet_if_empty ' )
48
- let g: bullets_delete_last_bullet_if_empty = 1
47
+ if ! exists (' g:bullets_process_last_bullet_if_empty ' )
48
+ let g: bullets_process_last_bullet_if_empty = 1
49
49
end
50
50
51
51
if ! exists (' g:bullets_line_spacing' )
@@ -573,8 +573,12 @@ fun! s:insert_new_bullet()
573
573
if l: bullet .text_after_bullet == # ' '
574
574
" We don't want to create a new bullet if the previous one was not used,
575
575
" instead we want to delete the empty bullet - like word processors do
576
- if g: bullets_delete_last_bullet_if_empty
577
- call setline (l: curr_line_num , ' ' )
576
+ if g: bullets_process_last_bullet_if_empty
577
+ if g: bullets_process_last_bullet_if_empty == 1
578
+ call setline (l: curr_line_num , ' ' )
579
+ elseif g: bullets_process_last_bullet_if_empty == 2
580
+ call <SID> change_bullet_level (1 , 0 )
581
+ endif
578
582
let l: send_return = 0
579
583
endif
580
584
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 271
271
TEXT
272
272
end
273
273
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_process_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
+
274
299
it 'does not delete the last bullet when configured not to' do
275
300
filename = "#{ SecureRandom . hex ( 6 ) } .txt"
276
301
write_file ( filename , <<-TEXT )
277
302
# Hello there
278
303
- this is the first bullet
279
304
TEXT
280
305
281
- vim . command 'let g:bullets_delete_last_bullet_if_empty = 0'
306
+ vim . command 'let g:bullets_process_last_bullet_if_empty = 0'
282
307
vim . edit filename
283
308
vim . type 'GA'
284
309
vim . feedkeys '\<cr>'
You can’t perform that action at this time.
0 commit comments