Formatting Lists in VIM

I would like to find a way to simplify list formatting in Vim.
I checked PAR and the standard Vim formatter.

pe

  1. this is my text this is my text this is my text 
 2. this is my text this is my text this is my text 
 3. this is my text this is my text this is my text 
 4. this is my text this is my text this is my text  

and this one

  - this is my text this is my text this is my text 
 - this is my text this is my text this is my text 
 - this is my text this is my text this is my text 
 - this is my text this is my text this is my text  

when I select the lines and make the default format to 42 with PAR and VIM, these are the results:


NUMBER LIST

formatting with par. :
par error:
(42) <= (0) + (50)

formatting with vim :

  1. this is my text this is my text this is
 my text 
 2. this is my text this is my text this is
 my text 
 3. this is my text this is my text this is
 my text 
 4. this is my text this is my text this is
    my text 

LIST with '-'

formatting with par. :
4 rows filtered (no change)

formatting with vim :

  - this is my text this is my text this is
   my text 
 - this is my text this is my text this is
   my text 
 - this is my text this is my text this is
   my text 
 - this is my text this is my text this is
   my text 

<imp> Vim does the best job formatting lists, but this is not true on a numbered list either.
Par has many problem formatting lists, even when I use the prefix ("p"), for example:
'<,'>! par w42p4dh or '<,'>! par w42p3dh

Does anyone know how to properly format lists without problems?

+7
source share
1 answer

Try set fo+=n . From :help fo-table :

 n When formatting text, recognize numbered lists. This actually uses the 'formatlistpat' option, thus any kind of list can be used. The indent of the text after the number is used for the next line. The default is to find a number, optionally followed by '.', ':', ')', ']' or '}'. Note that 'autoindent' must be set too. Doesn't work well together with "2". Example: 1. the first item wraps 2. the second item 
+6
source

All Articles