macdown
macdown copied to clipboard
Use tab to indent list items
Just saw this GIF (from this post):
Currently MacDown allows cmd+] for indentation, but most editors (see TextEdit, Pages, MS Word, etc.) use tab for that purpose. Even I sometimes need to remind myself tab doesn’t work that way in MacDown.
AFAIK it doesn’t really make sense to insert tabs in the first line of a list item. But I’m not sure whether it’s just me. Please offer your thought on this, and if it does make sense I’ll start implementing it after the next release.
It seems that the most prominent behaviour among rich text editors is the treat tab as indent only when the cursor is right after the item marker. So we should match for something like
^\s*[\*\+\-(\d+\.)]\s$
in the line before the cursor. If it matches, we treat tab as indent. Otherwise we perform normal tab operations.
and maybe also remove indentation by hitting delete key?
Yes, that makes sense too. Thanks!
I’ve played with the idea and come up with a custom build here: http://d.pr/f/1iFg9
The indent/unindent behaviour is there, but I feel that it should probably do more than just indenting. But I’m out of ideas now. If anyone’s got an idea, please tell me how I may proceed.
don't have time to play with the build right now, will try tonight i hope. My initial thought is that when i encounter tab as an indent / unindent mechanism it's tab for indent and shift tab for unindent. delete sounds really weird to me. Also, in my experience it either works when the cursor is at the beginning of the line OR when multiple characters of the line have been selected.
Yeah, after playing with it I feel frustrated that it will let me use tab to indent but shift+tab won't unindent. The idea of removing indentation from a selected block of text by hitting the delete key seems ... very wrong, but i'm not seeing evidence of that being implemented.
I kind of feel the same way. Delete is useful when you really want to delete the list marker, and it can be disturbing for people who are used to other means for un-indenting (cmd-[, for example). I’ll make another one based one shift-tab and see if it works better.
Is there any update on this? I would really like to see tabbing in lists.
I’m having troubles deciding when tabs should be tabs and when indents. Some candidates include...
- Tab-indent only works if a list item is “empty”. This reserve the possibility to use tabs inside a list item, but might not be most people want (or is it?).
- Tab-indent works at the beginning of a list item. Say if you have a list item
* foo
, hitting tab with cursor between the star andf
indents it.
The main problem here, however, is that we need a way to somehow “know” the cursor is inside a list item, and it is not easy. The most trivial solution is to check whether the current line matches /^\s+[-\*\+]\s/
(something like that), but that’s naive at best, and is bound to produce false positives that may be annoying.
On the other hand, even if we have a way to detect the syntax state precisely (by means still under development), it might still be too expensive. But without even seeing implementation it’s hard to make a decision.
I’m pretty busy recently, but when I have time I might implement one of the above solution. I can’t promise a timeline for this though.
Little +1 from me too, absolutely love MacDown :smile:
Perhaps a good reference would be Sublime Text 3 with its MarkdownEditing plugin. It does exactly this with Tab and Shift+Tab when you're in a list :smile:
Sublime seems to allow you to have any number of spaces after the - for it to indent, i.e. something more like this:
^\s*[\*\+\-(\d+\.)]\s+$
I was looking into MacDown as my go-to Markdown editor. For me, the lack of the tab
-indention feature is a really frustrating.
I second the request to implement the Sublime Text MarkdownEditing behavior: Let tab
indent / cascade the bullet item if the cursor is on an empty bullet line.
(Side note: My German keyboard layout prevents me from using cmd-[
as a replacement. I see that you cannot support every keyboard layout out there, though.)
Is there a way to indent text in MarkDown like Tab in regular text editor? I mean like Indention in Code not in list.
Just wanted to +1 this issue. Having tab indentation would be really helpful. I'm so used with that from other applications that the number of times I have a level 1 bullet with a tab afterwards is silly. :-)
For the record, I would like:
- Pressing tab with the cursor at the beginning of a bullet/numbered line, no matter if it contains text or not, shifts right.
- Both shift-tab and backspace at the same position shifts left.
@hjsl Backspace? What if one literally wants to "backspace"? AFAIK most editors do Shift + Tab only.
@franklinyu I find it rare to actually want to "backspace" (i.e. delete the space and *
). I work quite a lot with lists, so changing indentation level is a much more common operation. To separate from the two operations, perhaps backspace after the *
(with space) reduces indentation, while backspace directly after *
removes the character? Or using selections; selecting the space and/or *
would actually remove it when you press backspace, overriding any "indentation logic`.
With that said, I understand if it would be confusing to some, so if "only" shift-tab works, thats ok too.
The most common reason I have to remove a bullet would be if I want to end the list. In that case, I prefer editors which if I press Enter on an empty bullet removes the bullet from that line and adds a blank line there instead.
Thank you for your reply。 Is it possible to add a configuration to choose how to auto add the symbol。 Just like
* title
- child1
not
* title
* child1
@lalala8462 You mean the marker in source code or in rendered HTML?
Proposal: While being within a bulleted or numbered list TAB and shift-TAB should increase/decrease indention regardless of where on the line you are and regardless of whether text is selected or not.
User Experience Design Rationale
- This pattern is common place in all kind of rich text editing in web apps and Desktop apps.
- The alternative
⌘ [
and⌘ ]
is a convenient two key shortcut on English keyboards, which you can easily trigger blindly, but not on other keyboards, e.g. on my German keyboard a square bracket requires another modifier, so effectively⌘ ⌥ 5
and⌘ ⌥ 6
, which you cannot operate that simply. - Good usability always optimizes for the main use cases rather than edge cases: Inserting a literal TAB while being in a bulleted/numbered list is the absolute exception, whereas indenting would be what you mainly want to do, hence should get the more convenient shortcut.
- The only valid use case I could mentally come up with is inserting a literal tab somewhere in a line which started with list markup is somewhere within a very exotic codeblock.
- But AFAIK the parser should without doubt know that we are in a bulleted list and not somewhere in that forementioned codeblock.
- And even if in doubt, again, optimize for the main use case rather than that edge case.