Automatically keep numbered list ordered in editor (adding/removing/swapping/pasting)

Facing the same issue mentioned by @Spduck . However, when you go to preview mode the numbering corrects itself but it goes back to incorrect order when switching to editing mode again.

That’s just markdown; the numbering in source doesn’t matter until it’s rendered. You can change every number to 1. and it will be replaced with the correct ordinal at render time (reading view, print, publish, etc)

1 Like

I’ll just throw my related issue in here as well.

Pressing Shift-Tab on a list correctly updated the number for the level it is moved to, but pressing Enter on an empty lines only changes the indent while keeping the number the same

6 Likes

Anyone have a solution to fix list numbering in edit mode? A “Renumber List” command that could be called from the command palette or bound to a hotkey would be excellent…

also, related post: What is the easiest way to renumber lists?

2 Likes

If you get wrong numbering from pressing Enter twice, you can undo or reindent and then use Shift+Tab to get the right behavior.

1 Like

Whenever renumbering gets worked on, remember copy/cut and paste scenarios:

cut list items and paste

3 Likes

Set hotkey for ‘Toggle number list’. Place the cursor anywhere in the list and press hotkey twice. It would work.

4 Likes

So seeing as adding new lines to a numbered list works automatically. It’s really weird that the application, at this stage in development, still has this problem. Where if you delete a line, the numbers don’t auto fix itself.

  • yeah I can use a plugin to fix them
    But we shouldn’t need to, it should be automatic/instant

  • yeah it doesn’t matter in reading mode
    I don’t use reading mode, most people probably don’t. They use Live Preview

10 Likes

I would also expect automatic list reordering to be default behavior. After all, it is what the user actually wants 100% of the time. Yeah, you can do it manually with the tab/shift-tab dance, but the whole point of an advanced Markdown editor is that you don’t do everything manually yourself.

So yeah, +1 from me :slight_smile:

3 Likes

BTW, noticed just recently in Mastodon that Erin Kissane was checking out new software for note taking and dropped Obsidian from the shortlist because of the missing reordering. (She ended up staying in Notion.)

1 Like

I also agree that this feature will be very useful. Typora handles this by default.

1 Like

Would love this feature, and a suggested solution I’ve seen elsewhere is a generic ordered list indicator (#) to keep existing functionality intact:

#)
#)
#)

Resolves to:

1 Like

A generic indicator would be incompatible with other Markdown apps.

Kinda new user, so I just encountered this, today.
I was moving items in the list up and down in the list (hotkey alt+arrow, for me), and the numbers didn’t change.
While I definitely think a formal solution is needed, I have found a decent workaround:

  1. Goto the first item in the list.
  2. Change the number to 1.
  3. Put your cursor at the start of the text on the next line.
  4. Backspace until you’ve deleted the number on that line, and continue until that text is on the end of the previous line (the line now numbered 1).
  5. Hit Enter.
    1. The text will jump to the next line, numbered as 2, and all of the subsequent lines will reorder correctly.
    2. This works independently at each indent level. So, if first level of the list is out of order, and then one point has a sub list that is also out of order, you will have to repeat the process on that sub list.

When this happened to me, the first thing I looked for was some right-click functionality like “Reorder List.”
Would be nice if you could just right-click anywhere in a numbered list and it would show this option, and it would renumber the entire thing at every indent point.

A simpler workaround mentioned in another comment is to indent and then unindent the top list item.

666

Problem: I attempted to append “5. Fig” after “4. Date” (by first clicking at the end of “4. Date” and then pressing Enter), but all nodes from “2. Sunflower” and beyond were erroneously renumbered.

Methods attempted: I tried clicking on “Sunflower”, then indenting and unindenting, but it proved ineffective, as shown in the GIF.

I tried toggling number list (by collapsing internal nodes, switching to bullet points, and then back to numbered lists), as illustrated in the GIF. It did indeed restore the numbering in the target layer, but it had a severe side effect: all the numbers in the internal number list became “1,” and all internal bullet lists were converted into number lists. This solved one issue but created more significant issues.

Question: Do the tab/shift-tab trick and the toggle number list trick mentioned in previous posts genuinely have no effect in this scenario, or are they effective, just I was using them incorrectly?

Wow, that’s strange. Try it without selecting the whole list — just put the cursor in the topmost list item and indent and unindent it. (That behavior you’re seeing probably shouldn’t be happening, tho.)

88

Thank you. this trick indeed fixes the numbering for the current level, but somehow disrupts the numbering for the next level. As shown in the GIF… However, there seems a workaround found during the tests: using Shift+Enter after “4.Date” seems can prevent automatic renumbering of Sunflower and its subsequent items. Still quite troublesome, but well better than nothing…

BTW, it seems that whether “Sunflower” and its subsequent items are renumbered depends on whether Maple’s internal levels include bullet lists. As shown in the GIF, if there’s a bullet list inside, Sunflower gets incorrectly renumbered. If there’s not, Sunflower remains unaffected (just sharing a small finding).

Looks like there may be some bugs here worth reporting (if they haven’t been already).

Use case or problem

When creating an ordered list in editor mode, Obsidian by default will auto-increment the new line item automatically.

1. Blue
2. Red
3. Yellow
4. Green
5. Cyan

However, if the user needs to rearrange items, such as moving Cyan to position two, this requires manual changes to get the list to update properly. Using Obsidian’s swap line up shortcut, this would result in:

1. Blue
5. Cyan
2. Red
3. Yellow
4. Green

Proposed solution

Since the user wants to use an ordered list, I’m making the assumption that Obsidian should automatically update the ordered list to the correct number when existing items are moved up and down in a list

Current workaround (optional)

User needs to manually update all numbers.

Some may propose that we allow the user to use the following markdown pattern to avoid ordering at all

1. Blue
1. Red
1. Yellow
1. Green
1. Cyan

But I do think it’s valuable to actually see what number each item is. I’m just thinking it’d be a good UX enhancement to have Obsidian manage that for us instead.

24 Likes