Monday, June 13, 2022

Re: Numbered lists and indentation

On 2022-06-13, 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:
>
> 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?

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

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20220613164631.GB20513%40phoenix.

No comments: