atom / language-gfm

GitHub Flavored Markdown in Atom
MIT License
101 stars 107 forks source link

Automatically insert a new list item #12

Open andytlr opened 10 years ago

andytlr commented 10 years ago

In the most simple form this would insert an empty list item when you hit return.

* List item
* Another item| <--- return

Would insert a new item:

* List item
* Another item
* |

Hitting return again would clear that item.

* List item
* Another item

|

Doing so mid list would also insert a new item, I.e.:

* List item
* |
* Another item

This should work with -, + and - [ ] as well as *. It probably gets more tricky with ordered lists because you'd want to increment the number.

1. List item
2. Another item
3. |

That's probably hard but not as hard as inserting a new list item mid-list and re-numbering all of the items so you don't end up with:

1. First
2. |
2. Second
3. Third

I use a package in Sublime that does something similar, but it isn't great. Byword probably has the best implementation which I've put in gif form:

new list item

I've tried to hack something in with snippets with no success. I thought a solution might be some kind of context aware keymap. But I'm lost as to where to start.

kevinsawicki commented 10 years ago

Yeah, this would need to be handled explicitly in some code that binds to inserting text in the editor the same way that bracket-matcher completes the closing bracket as you type.

jtkiley commented 10 years ago

I'd also like this. I tend to have a markdown outline open all the time to collect notes for any given project.

maxheld83 commented 10 years ago

+1

jonmagic commented 9 years ago

I'm curious if it makes sense for a feature like this to live in the language-gfm package or in a separate package? I went ahead and started working on a separate package (https://atom.io/packages/gfm-lists) that has basic list support for GitHub Markdown.

gfm-lists

It could definitely use some refinement though :)

jtkiley commented 9 years ago

This looks cool to me.

It doesn't appear to clear the last empty item it you hit return a second time. I can make an issue if you like.

One thing that may be worth discussing is whether the enumerated list should fill sequential numbers or just 1. for every item. When I'm using markdown, I use 1. for every enumerated item because I frequently reorder, delete, and insert items. It's a design feature of markdown that I like, but I'm not sure how many people use it like I do.

jonmagic commented 9 years ago

It doesn't appear to clear the last empty item it you hit return a second time. I can make an issue if you like.

:+1: Pull requests are welcome too :grin:

One thing that may be worth discussing is whether the enumerated list should fill sequential numbers or just 1. for every item. When I'm using markdown, I use 1. for every enumerated item because I frequently reorder, delete, and insert items. It's a design feature of markdown that I like, but I'm not sure how many people use it like I do.

Definitely create an issue for this and let's chat through it. I really like that feature of markdown as well and honestly it would make the code much simpler.

burodepeper commented 8 years ago

Hello all, I've just pushed an update of my language-markdown package that implements automatically inserting new list-items (except after empty ones) for all types of list-items in Markdown. I'm also thinking of overriding the behavior of tab and shift + tab to manipulate list-item indentation. I'd appreciate if you could take a look. Any feedback is welcome.

/cc @andytlr @kevinsawicki @jtkiley @jonmagic @lee-dohm @maxheld83