What is the best way to create a numbered list in Markdown format? I currently have to manually enter the number I want to appear, but if I add items, I have to renumber them all.
4 Answers
That should happen automatically (at least in SO flavored MD):
- test 1
- test 2
The code I used it:
1. test 1
1. test 2
The same works for GitHub flavored MD: https://gist.github.com/3489721
You can test it here: https://meta.stackexchange.com/questions/3122/formatting-sandbox
-
Got it, it doesn't work in vanilla Markdown, but most variants support this. – user1027169 Dec 10 '12 at 21:10
-
That's strange because the official markdown also support numbered lists: http://daringfireball.net/projects/markdown/syntax#list – PeeHaa Dec 10 '12 at 21:57
-
It looks like you're right, I asked this so long ago I don't remember what implementation I was using. I have since been using Pandoc and Github-flavored Markdown and have not had this issue. – user1027169 Dec 10 '12 at 23:09
-
Visual Studio Code supports this feature. – psnx Jun 10 '21 at 14:43
if you type the first one with a one like this 1. lorem
then as long as
the rest have a space after the dot then it should work
1. lorem
4. hello
3. blah blah blah
you should get this:
- lorem
- hello
- blah blah blah

- 111
- 1
- 2
-
if i have a code block in between the numbers reset to 1, anyway i can avoid that? – Nivethan Feb 18 '23 at 09:04
-
never mind i figured out and wrote an answer to this question itself https://stackoverflow.com/a/75492769/12719767 – Nivethan Feb 18 '23 at 10:54
OP's Question is easy to solve by adding a number with a dot then a space after. eg: 1.
we can keep use the same 1.
for all the items so we don't have to number everything manually and even if you remove the second item you don't have to rename all numbers below
- item one
- item two
- item three
But I faced a problem while creating a GitHub gist. auto numbering was not working if i have a code block between them.
Problem if you have a code block in between
- step one
- step two
// a sample code block
- step three (this should be
3.
) - step four
Simple Solution
in order to solve this you need to add four spaces to indent content between bullet points
- step one
- step two
// a sample code block
- step three
- step four
Note: you can click on the "edit" button below on this answer to see the underlying Markdown code but click on the cancel button instead of save!

- 2,339
- 19
- 22
If you need add any comment/description/whatever under an item in the list. Only this option solved my case.
<ol>
<li>option 1</li>
<li>option 2</li>
<li>option 3</li>
</ol>

- 205
- 2
- 6
-
No, it doesn't help. Because the question was not how to make a list in HTML, it was how to make a list in **Markdown** (which can then be converted to HTML but that's not the point). – Eric Aya Sep 02 '21 at 11:42
-
-
Question about how to make **automatically numbered list**. It is not only about add item in the end. It is also about add item in the middle of the list. I see main inconvenience around 'if I insert items in the list'. Can't find another option that can solve it. – ilu Sep 02 '21 at 12:26
-
I never said it was "only about add item in the end". I'm saying that your answer is off-topic. Sorry but it looks like you're misunderstanding the question. Did you try [Timely10's answer](https://stackoverflow.com/a/66858660/2227743) for example? It does insert an element in the middle and gets *automatic numbering*, and it's using **Markdown** as asked by OP. – Eric Aya Sep 02 '21 at 12:29
-
Timely10's answer works in case if you have only list as it is. Try to add any comment/description/whatever under an item in the list. – ilu Sep 02 '21 at 12:35
-