The context
I've the following options in my vimrc
set formatoptions=cnroqj
set textwidth=80
When editing tex
files, lines whose content is longer than &textwidth
is
splitted and formatted as it follows
% - foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
% foo foo foo foo foo foo foo foo foo foo foo foo
%
% 1. bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar
% bar bar bar bar bar bar bar bar bar bar bar
When editing cpp
files, lines whose content is longer than &textwidth
is
splitted and formatted as it follows
// - foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo foo
// foo foo foo foo foo foo foo foo foo foo foo
//
// 1. bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar bar
// bar bar bar bar bar bar bar bar bar bar bar bar
As you can see, in files whose filetype is cpp
, lists present in comments
lines that start with the -
character are not formatted when reaching the
value of &textwidth
just as happens with files whsoe filetype is tex
.
The question
How can I make lists from comment lines that start with the -
character to be
automatically indented in files whose filetype is cpp
?
Additional context
I've noticed that the
/usr/share/vim/vim82/ftplugin/c.vim
file sets the value of theformatoptions
option forcpp
files. However, even when I set the same value for the&formatoptions
option in both buffers (tex
andcpp
) I got the same behavior.Some people recommend modifying the
comments
option, modifying theformatlistpat
option (also here), setting theautoindent
option but I'm not sure which one I must modify for this specific case.