Numbered lists and indentation

13 views
Skip to first unread message

Rand Pritelrohm

unread,
Jun 13, 2022, 12:29:04 PM6/13/22
to vim...@googlegroups.com
Hello,

Despite having read a lot of posts, I have not found a solution to my
problem.
So I am sorry if the topic has already been discussed.

I would like to write texts with numbered lists, but I face problems
with indentation from the second line of each items:

Hereunder what I would like to have:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam porta
ac ligula vitae semper. Proin placerat nunc ac dui vestibulum, non
rutrum neque dignissim.

1. Sed quis volutpat sem, vel ullamcorper libero. Mauris ut
augue nec risus ultricies facilisis. Nam egestas dui sodales
consequat facilisis.
2. Nam id faucibus nisi. Mauris ligula felis, egestas eget
mauris non, efficitur hendrerit magna. Duis vel porta lacus,
quis suscipit quam. Vivamus egestas enim ac tortor tincidunt,
a ultricies ex vestibulum.

...
...

99. Fusce a massa ultricies, porta ligula in, posuere diam.
Nullam congue neque a ligula accumsan tincidunt.

But this is what I get when I type the text:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam porta
ac ligula vitae semper. Proin placerat nunc ac dui vestibulum, non
rutrum neque dignissim.

1. Sed quis volutpat sem, vel ullamcorper libero. Mauris ut
augue nec risus ultricies facilisis. Nam egestas dui sodales
consequat facilisis.
2. Nam id faucibus nisi. Mauris ligula felis, egestas eget
mauris non, efficitur hendrerit magna. Duis vel porta lacus,
quis suscipit quam. Vivamus egestas enim ac tortor tincidunt, a
ultricies ex vestibulum.

...
...

99. Fusce a massa ultricies, porta ligula in, posuere diam.
Nullam congue neque a ligula accumsan tincidunt.

I have, in my ~/.vimrc
set autoindent

I tried
set formatlistpat=^\\s*[0-9*]\\+[\\]:.)}\\t\ ]\\s*

And I also tried
set formatlistpat=^\\s*[0-9*]\\+[\\]:.)}\\t\ ]\\s*
set formatoptions-=c
set comments-=mb:*

None of what I tried works.

Any clue to achieve what I fight for?

Thank you in advance for your help.

--
Rand Pritelrohm
*Linux && *BSD

Gary Johnson

unread,
Jun 13, 2022, 12:46:39 PM6/13/22
to vim...@googlegroups.com
The simplest way to achieve that is to add the 'n' flag to
'formatoptions', e.g.,

:set fo+=n

See

:help fo-n

For what it's worth, I also have this in my vimrc:

" Require the first character following the number to not be a
" space to avoid the improper indentation of lines following a
" line that happens to begin with a number.

set formatlistpat=^\\s*\\d\\+[\\]:.)}][\\t\ ]\\s*

HTH,
Gary

Rand Pritelrohm

unread,
Jun 13, 2022, 1:11:18 PM6/13/22
to vim...@googlegroups.com
On Mon, 13 Jun 2022 09:46:31 -0700
Gary Johnson <gary...@spocom.com> wrote:

[...]
>
>The simplest way to achieve that is to add the 'n' flag to
>'formatoptions', e.g.,
>
> :set fo+=n
>
>See
>
> :help fo-n
>
>For what it's worth, I also have this in my vimrc:
>
> " Require the first character following the number to not be a
> " space to avoid the improper indentation of lines following a
> " line that happens to begin with a number.
>
> set formatlistpat=^\\s*\\d\\+[\\]:.)}][\\t\ ]\\s*
>
>HTH,
>Gary
>

Hello Gary,

Thank you for your quick and efficient response.
This exactly what I searched for.

Shame on me, I did not explore the 'formatoption' option.

Cordially,

Rand Protelrohm

unread,
Jun 13, 2022, 6:42:44 PM6/13/22
to v...@vim.org
Hello,

Despite having read a lot of posts, I have not found a solution to my
problem.

I would like to write texts with numbered lists, but I face problems
with indentation from the second line of each items:

Hereunder what I would like to have:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam porta
ac ligula vitae semper. Proin placerat nunc ac dui vestibulum, non
rutrum neque dignissim.

1. Sed quis volutpat sem, vel ullamcorper libero. Mauris ut
augue nec risus ultricies facilisis. Nam egestas dui sodales
consequat facilisis.
2. Nam id faucibus nisi. Mauris ligula felis, egestas eget
mauris non, efficitur hendrerit magna. Duis vel porta lacus,
quis suscipit quam. Vivamus egestas enim ac tortor tincidunt,
a ultricies ex vestibulum.

...
...

99. Fusce a massa ultricies, porta ligula in, posuere diam.
Nullam congue neque a ligula accumsan tincidunt.


But this is what I have when I type the text:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Etiam porta
ac ligula vitae semper. Proin placerat nunc ac dui vestibulum, non
rutrum neque dignissim.

1. Sed quis volutpat sem, vel ullamcorper libero. Mauris ut
augue nec risus ultricies facilisis. Nam egestas dui sodales
consequat facilisis.
2. Nam id faucibus nisi. Mauris ligula felis, egestas eget
mauris non, efficitur hendrerit magna. Duis vel porta lacus,
quis suscipit quam. Vivamus egestas enim ac tortor tincidunt, a
ultricies ex vestibulum.

...
...

99. Fusce a massa ultricies, porta ligula in, posuere diam.
Nullam congue neque a ligula accumsan tincidunt.

I have, in my ~/.vimrc
set autoindent

I tried
set formatlistpat=^\\s*[0-9*]\\+[\\]:.)}\\t\ ]\\s*

And also tried
set formatlistpat=^\\s*[0-9*]\\+[\\]:.)}\\t\ ]\\s*
set formatoptions-=c
set comments-=mb:*

None of what I tried works.

Any clue to achieve what I fight for?

regards,

--
Rand Pritelrohm
~~ *NIX & *BSD ~~

meine

unread,
Jun 14, 2022, 11:22:35 AM6/14/22
to vim...@googlegroups.com
On Mon, Jun 13, 2022 at 06:02:08PM +0200, Rand Pritelrohm wrote:
> Hello,
>
> Despite having read a lot of posts, I have not found a solution to my
> problem.
> So I am sorry if the topic has already been discussed.
>
> I would like to write texts with numbered lists, but I face problems
> with indentation from the second line of each items:

It depends on if you want to process your text from Vim to make it
'print ready' or not.

The solution Gary posted makes your text line out well in Vim.

When you process your text with (eg.) Pandoc or LaTeX, the outlining is
done for you and you don't have to bother about indentation.

Pandoc is very practical to provide clean PDF-files with hardly any
extra work when you use basic (daring fireball) Markdown. Here you even
don't have to bother about the numbering, '1. ' for each numbered item
is enough to get a numbered list.

See https://pandoc.org

Kind Regards,

//meine

Rand Pritelrohm

unread,
Jun 14, 2022, 1:27:25 PM6/14/22
to vim...@googlegroups.com
Hello Meine,

Thank you for your participation.

I am a user of both i) Pandoc to generate HTML (markdown + yaml
headers) and ii) {Xe,Lua}TeX to generate PDF.

What I was aiming to have and what lead to my initial post was to have
"clean" plain text files correctly indented with numbered lists.

So Gary's solution is the way to go for me.

Cordially,
Reply all
Reply to author
Forward
0 new messages