erinata / SublimeBullet

This is a Sublime Text plugin for markdown style Bullet points and Number lists. It automatically add * and - for unordered lists, > for blockquotes, and numbered items for number lists.
6 stars 8 forks source link

Nested lists #2

Closed alehandrof closed 12 years ago

alehandrof commented 12 years ago

I'm not sure what is the best way to handle this, but I think an unobtrusive way to indent and unindent lists would be useful.

An idea would be to use Tab in the following position to create a nested list:

* List item
* List item
* |

Similarly, pressing Shift+Tab in the following position would unindent the list:

* List item
* List item
    * List item
    * List item
    * |
erinata commented 12 years ago

Now you can use Tab to indent and Backspace to unindent. and this only work for empty bullet. (and it's still buggy, I know)

I think what you are suggesting is a good way to go. Just that it's not possible under the current design. I guess I need to rewrite the plugin to make this work.

alehandrof commented 12 years ago

Thanks for looking into, but as you say, the current implementation is buggy.

Backspace works --- which I'm okay with as a keybinding instead of Shift+Tab --- but it breaks Undo, which I rather mind. (You can take all my keybindings away except for Ctrl+Z, Ctrl+Y and Ctrl+S :) )

I had more trouble with using tab to indent reliably. I think it works only when the caret is directly in front of the bullet, rather than separated from it by a space?

Anyway, I hope you get some chance to see if you can work this out. I keep TODO lists in a combination of Markdown & orgmode and these extensions would be very useful :)

erinata commented 12 years ago

Actually it has nothing to do with which key I choose to bind ...................Now the implementation didn't use any key binding, it just look at the document and guess whether you want to indent or not (say if it see * and no space after that it guesses you want to unindent, and * with a tab after that it guesses that you want to indent).

Very stupid method indeed. I am doing that because I know NOTHING about python before I write this plugin. (Yup.....by Nothing I mean I don't even know how to write "if" statement or define a method in python.) , and nothing about Sublime API............. ....... If I have time I will learn more things about Python and Sublime Text API and make the plugin better. :P ( Say at least I should just bind 2 keys for indent and unindent actions instead of using the stupid guessing method )

alehandrof commented 12 years ago

Hey. I know less Python than you do, so I'm afraid I can't help you out. If you want to pursue this, there are several talented plugin developers in the sublime forums who might be able to help. Maybe using bindings (with an appropriate scope as context) to call up appropriate commands, might make things easier. (Maybe.)

erinata commented 12 years ago

So if you update to the current version (0.3.0). The tab and shift+tab indenting and unindenting should work as expected.

alehandrof commented 12 years ago

Yup. It works great. Thank you!

I discovered that you need to fiddle to switch from unordered to ordered lists (or vice-versa) and to restart the numbers' countdown when nesting an ordered list within an ordered list. I can't think of any particularly elegant suggestion to deal with this. There was a forum post that mentioned that TextMate had some similar functionality to this plugin, so that may be a place to look. (I don't have a Mac, so I can't help with that.)