Skip to content

Commit 4637e51

Browse files
authored
Merge pull request #56 from kaymmm/nested-renumber
Add visual mode promoting/demoting, nested renumbering, and auto-renumbering
2 parents 0976e87 + 3cb084d commit 4637e51

7 files changed

Lines changed: 821 additions & 99 deletions

File tree

README.md

Lines changed: 151 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ to go to the next line, a new list item will be created.
3434

3535
# Configuration
3636

37+
### Filetypes
38+
3739
You can choose which file types this plugin will work on:
3840

3941
```vim
@@ -46,6 +48,151 @@ let g:bullets_enabled_file_types = [
4648
\]
4749
```
4850

51+
You can disable this plugin for empty buffers (no filetype):
52+
53+
```vim
54+
let g:bullets_enable_in_empty_buffers = 0 " default = 1
55+
```
56+
57+
Enable/disable default key mappings:
58+
59+
```vim
60+
let g:bullets_set_mappings = 0 " default = 1
61+
```
62+
63+
Add a leader key before default mappings:
64+
65+
```vim
66+
let g:bullets_mapping_leader = '<M-b>' " default = ''
67+
```
68+
69+
Enable/disable deleting the last empty bullet when hitting `<cr>` (insert mode) or `o` (normal mode):
70+
71+
```vim
72+
let g:bullets_delete_last_bullet_if_empty = 0 " default = 1
73+
```
74+
75+
Line spacing between bullets (1 = no blank lines, 2 = one blank line, etc.):
76+
77+
```vim
78+
let g:bullets_line_spacing = 2 " default = 1
79+
```
80+
81+
Don't/add extra padding between the bullet and text when bullets are multiple characters long:
82+
83+
```vim
84+
let g:bullets_pad_right = 1 " default = 1
85+
" I. text
86+
" II. text
87+
" III. text
88+
" IV. text
89+
" V. text
90+
" ^ extra spaces to align the text with the longest bullet
91+
92+
let g:bullets_pad_right = 0
93+
" I. text
94+
" II. text
95+
" III. text
96+
" IV. text
97+
" ^ no extra space between bullet and text
98+
```
99+
100+
Maximum number of alphabetic characters to use for bullets:
101+
102+
```vim
103+
let g:bullets_max_alpha_characters = 2 " default = 2
104+
" ...
105+
" y. text
106+
" z. text
107+
" aa. text
108+
" ab. text
109+
110+
let g:bullets_max_alpha_characters = 1
111+
" ...
112+
" y. text
113+
" z. text
114+
" text
115+
```
116+
117+
Nested outline bullet levels:
118+
119+
```vim
120+
let g:bullets_outline_levels = ['ROM', 'ABC', 'num', 'abc', 'rom', 'std-', 'std*', 'std+'] " default
121+
" Ordered list containing the heirarchical bullet levels, starting from the outer most level.
122+
" Available bullet level options (cannot use the same marker more than once)
123+
" ROM/rom = upper/lower case Roman numerals (e.g., I, II, III, IV)
124+
" ABC/abc = upper/lower case alphabetic characters (e.g., A, B, C)
125+
" std[-/*/+] = standard bullets using a hyphen (-), asterisk (*), or plus (+) as the marker.
126+
" chk = checkbox (- [ ])
127+
128+
let g:bullets_outline_levels = ['num', 'abc', 'std*']
129+
" Example [keys pressed to get this bullet]:
130+
" 1. first parent
131+
" a. child bullet [ <cr><C-t> ]
132+
" - unordered bullet [ <cr><C-t> ]
133+
" b. second child bullet [ <cr><C-d> ]
134+
" 2. second parent [ <cr><C-d> ]
135+
```
136+
137+
Enable/disable automatically renumbering the current ordered bullet list when changing the indent level of bullets or inserting a new bullet:
138+
139+
```vim
140+
let g:bullets_renumber_on_change = 1 " default = 1
141+
" Example 1:
142+
" 1. first existing bullet
143+
" a. second existing bullet [ hit <C-t> ]
144+
" 2. third existing bullet [ this got renumbered 3 -> 2 when bullet 2 got demoted ]
145+
"
146+
" Example 2:
147+
" 1. first existing bullet
148+
" 2. second existing bullet [ use <cr>/o to add a new bullet below this ]
149+
" 3. new bullet
150+
" 4. third existing bullet [ this got renumbered 3 -> 2 when bullet 2 got demoted ]
151+
152+
let g:bullets_renumber_on_change = 0
153+
" Example:
154+
" 1. first existing bullet
155+
" a. second existing bullet [ hit <C-t> ]
156+
" 3. third existing bullet [ no renumbering so this bullet remained `3` ]
157+
"
158+
" Example 2:
159+
" 1. first existing bullet
160+
" 2. second existing bullet [ use <cr>/o to add a new bullet below this ]
161+
" 3. new bullet
162+
" 3. third existing bullet [ no renumbering so this bullet remained `3` ]
163+
```
164+
165+
# Mappings
166+
167+
* Insert new bullet in INSERT mode: `<cr>` (Return key)
168+
* Same as <cr> in case you want to unmap <cr> in INSERT mode (compatibility depends on your terminal emulator): `<C-cr>`
169+
* Insert new bullet in NORMAL mode: `o`
170+
* Renumber current visual selection: `gN`
171+
* Renumber entire bullet list containing the cursor in NORMAL mode: gN
172+
* Toggle a checkbox in NORMAL mode: `<leader>x`
173+
* Demote a bullet (indent it, decrease bullet level, and make it a child of the previous bullet):
174+
+ NORMAL mode: `>>`
175+
+ INSERT mode: `<C-t>`
176+
+ VISUAL mode: `>`
177+
* Promote a bullet (unindent it and increase the bullet level):
178+
+ NORMAL mode: `<<`
179+
+ INSERT mode: `<C-d>`
180+
+ VISUAL mode: `>`
181+
182+
Disable default mappings:
183+
184+
```vim
185+
let g:bullets_set_mappings = 0
186+
```
187+
188+
Add a leader key before default mappings:
189+
190+
```vim
191+
let g:bullets_mapping_leader = '<M-b>'
192+
" Set <M-b> to the leader before all default mappings:
193+
" Example: renumbering becomes `<M-b>gN` instead of just `gN`
194+
```
195+
49196
Just add above to your .vimrc
50197

51198
# Documentation
@@ -93,11 +240,11 @@ Capybara integration testing. ❤️
93240
lines).
94241
- [x] add alphabetic list
95242
- [x] support for intelligent alphanumeric indented bullets e.g. 1. \t a. \t 1.
96-
- [ ] update documentation for nested bullets
243+
- [x] change nested outline levels in visual mode
244+
- [x] support renumbering of alphabetical, roman numerals, and nested lists
245+
- [x] update documentation for nested bullets
97246
- [ ] support for nested numerical bullets, e.g., 1. -> 1.1 -> 1.1.1, 1.1.2
98-
- [ ] change nested outline levels in visual mode
99-
- [ ] support renumbering of alphabetical, roman numerals, and nested lists
100-
- [ ] add option to turn non-bullet lines into new bullets with `C-t`/`>>`
247+
- [ ] add option to turn non-bullet lines into new bullets with `<C-t>`/`>>`/`>`
101248

102249
---
103250

doc/bullets.txt

Lines changed: 92 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,20 @@ types:
2727

2828
- Hyphenated lists
2929
* Star (or bullet) lists
30+
+ Plus (also bullet) lists
3031
- [ ] GFM markdown checkbox lists
3132
1. Numeric lists
3233
2) or this style of numeric lists
3334
a. alphabetic lists
3435
B) or this style of alphabetic
36+
i. Roman numeral lists
37+
II. or capitalized Roman numeral lists
3538
\item latex item lists
3639
**** Org mode headers
3740

41+
It supports nested (heirarchical) ordered lists/outlines using different types
42+
of bullet markers for each level.
43+
3844
It also provides support for wrapped text in a bullet, allowing you to use the
3945
`textwidth` feature in Vim seamlessly.
4046

@@ -72,6 +78,30 @@ GENERAL COMMANDS *bullets-commands*
7278
visual selection. Right padding is initalized to the
7379
first found bullet.
7480

81+
*bullets-:RenumberList*
82+
:RenumberList Renumbers all of the bullet lines in the current list.
83+
A blank line before/after the first/last bullet denotes
84+
the end of the list.
85+
86+
*bullets-:BulletDemote*
87+
:BulletDemote Demotes the current bullet by indenting it and changing
88+
its bullet type to the next level defined in
89+
g:bullets_outline_levels. Mapped to <C-t> in INSERT
90+
mode and `>>` in NORMAL mode.
91+
92+
*bullets-:BulletPromote*
93+
:BulletPromote Promotes the current bullet by unindenting it and
94+
changing its bullet type to the next level defined in
95+
g:bullets_outline_levels. Mapped to <C-d> in INSERT
96+
mode and `<<` in NORMAL mode by default.
97+
98+
*bullets-:BulletDemoteVisual*
99+
:BulletDemoteVisual Demotes the currently selected bullet(s) in VISUAL
100+
mode. Mapped to `>` in VISUAL mode by default.
101+
*bullets-:BulletPromoteVisual*
102+
:BulletPromoteVisual Promotes the currently selected bullet(s) in VISUAL
103+
mode. Mapped to `>` in VISUAL mode by default.
104+
75105
CONFIGURATION *bullets-configuration*
76106

77107
File types
@@ -161,6 +191,38 @@ that using auto commands.
161191
When changed to `0` this will disable alphabetic bullets altogether.
162192

163193

194+
Nested Outline Bullet Levels
195+
----------------------------
196+
You can create heirarchically nested outlines using indentation and different
197+
bullet types for each level of indentation. Define the type of bullet used for
198+
each level using the following ordered list:
199+
200+
`let g:bullets_outline_levels = ['ROM', 'ABC', 'num', 'abc', 'rom', 'std-',`
201+
` \ 'std*', 'std+']`
202+
203+
Demoting a bullet ([I]<C-t>, [N]`>>`, [V]`>`) will increase its indentation and use the
204+
next bullet level defined in this list. Similarly, promoting the bullet
205+
([I]<C-d>, [N]`<<`, [V]`<`) will decrease the bullet
206+
indentation and use the previous bullet level. Promoting a top-level bullet
207+
will remove the bullet and demoting a bottom-level bullet will indent, but not
208+
change the bullet marker.
209+
210+
211+
Renumber Bullets on Change
212+
--------------------------
213+
By default, inserting a new bullet or promoting/demoting an existing bullet in
214+
the middle of a list will cause all of the list items, including nested
215+
bullets, to be renumbered. You can disable renumbering using the following:
216+
217+
`let g:bullets_renumber_on_change = 0`
218+
219+
The current list is defined by blank lines surrounding the first/last bullet
220+
items, taking into consideration the setting in g:bullets_line_spacing.
221+
222+
You can always manually renumber the current list or visual selection using
223+
`gN` in NORMAL or VISUAL mode.
224+
225+
164226
INSERTING BULLETS *bullets-insert-new-bullet*
165227

166228
When a supported file type is opened (see |bullets-configuration|) you can start
@@ -184,8 +246,6 @@ Vim comes built in with support for indenting and de-indenting in INSERT mode.
184246
To indent the current bullet to the right: from insert mode press <CTRL-t>.
185247
To indent the current bullet to the left: from insert mode press <CTRL-d>.
186248

187-
Note: For <CTRL-d> to work properly you have to be at the end of the line.
188-
189249
For more information `:h i_CTRL-T` and `:h i_CTRL-D`
190250

191251

@@ -213,18 +273,48 @@ INSERT MODE
213273
*bullets-i_<C-cr>*
214274
<C-CR> Same as <CR>, in case you want to unmap <CR> in INSERT MODE.
215275

276+
*bullets-i_<C-d>*
277+
<C-D> Promotes the current bullet item by unindenting the line and
278+
changing the bullet to the previous type defined in
279+
g:bullets_outline_levels.
280+
281+
*bullets-i_<C-t>*
282+
<C-T> Demotes the current bullet item by indenting the line and changing
283+
the bullet to the next type defined in g:bullets_outline_levels.
284+
216285
NORMAL MODE
217286

218287
*bullets-o*
219288
o Inserts a new bullet list item. Same as <CR> in INSERT MODE.
220289

290+
*bullets-gN*
291+
gN Renumbers entire list containing the current cursor position.
292+
221293
*bullets-<leader>x*
222294
<leader>x Toggles the checkbox on the current line.
223295

296+
*bullets->>*
297+
>> Promotes the current bullet item by unindenting the line and
298+
changing the bullet to the next type defined in
299+
g:bullets_outline_levels.
300+
301+
*bullets-<<*
302+
<< Demotes the current bullet item by indenting the line and changing
303+
the bullet to the previous type defined in g:bullets_outline_levels.
304+
224305
VISUAL MODE
225306

226307
*bullets-v_gN*
227308
gN Renumbers selected bullet list items.
228309

310+
*bullets-v_>*
311+
> Promotes the currently selected bullet item(s) by unindenting the
312+
lines and changing the bullets to the next type defined in
313+
g:bullets_outline_levels.
314+
315+
*bullets-v_<*
316+
< Demotes the currently selected bullet item(s) by indenting the
317+
lines and changing the bullets to the previous type defined in
318+
g:bullets_outline_levels.
229319

230320
vim:tw=78:et:ft=help:norl:

0 commit comments

Comments
 (0)