vim already detects a leading dash as bullet in txt files and can reformat a bullet list nicely (visual selection + gq).
But when actually typing in a long line, starting with a bullet (dash) and when the line break kicks in, the second row is indented as if there was no bullet.
Desired behaviour: When the line break kicks in, the next line should (optionally) start a little more to the right, just like gq does on paragraphs with leading dahes.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications on the go with GitHub Mobile for iOS or Android.![]()
With
setlocal formatlistpat=^\s*\d\+[\]:.)}\t ]\s*\\\|^\\s*[-+*]\\s\\+ " instead of the default value formatlistpat=^\s*\d\+[\]:.)}\t ]\s* setlocal formatoptions+=n
the second row is indented after the line break kicks in.
I am super happy that there is a solution already!
I am just stumbling accross an error when applying the formatlistpat. This happens even when I try to set the default pattern!
:set formatlistpat=^\s*\d\+[\]:.)}\t ]\s*
E518: Unknown option: ]\s
I am probably missing something trivial?
I am using neovim-4.4 (in case this matters).
I missed that everything needs to be doubly escaped. Correct should be
setlocal formatlistpat=^\s*\d\+[\]:.)}\t ]\s*\\\|^\\s*[-+*]\\s\\+
—
vim already detects a leading dash as bullet in txt files and can reformat a bullet list nicely (visual selection + gq).
But when actually typing in a long line, starting with a bullet (dash) and when the line break kicks in, the second row is indented as if there was no bullet.
Desired behaviour: When the line break kicks in, the next line should (optionally) start a little more to the right, just like gq does on paragraphs with leading dahes.
First, thanks for all your ideas. So I am still convinced that it should work.
However, no success here.
See the code and my comments in between. I am opening vim /tmp/test.txt and
then do this:
:set formatoptions?
formatoptions=qjtn
:set formatlistpat?
formatlistpat=^\s*\d\+[\]:.)}\t ]\s*
(trying to apply that default, doubly escaped:)
:setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t ]\\s*
E518: Unknown option: ]\\s
(so, the doubly escaped default is not accepted?)
:setlocal formatlistpat=^\\s*\\d\\+[\\]:.)}\\t]\\s*
(ok, no error when removing the single space, strange...)
(test: numbered bullets still indent 2nd line as expected)
(test: dash bullets obviously do not indent as desired yet)
(test: without bullets the second line indents like the first - ok)
:setlocal formatlistpat=^\\s*-\\s*
(ok, no error)
:set breakindent?
nobreakindent
:setlocal breakindent
:set breakindentopt?
breakindentopt=
:setlocal breakindentopt=list:-1
E474: Invalid argument: breakindentopt=list:-1
(test: numbered bullets do not indent anymore)
(test: dash bullets do not indent either)
(test: without bullets: regression, no indent at all, always column 1)
(trying the or'ed variant:)
:setlocal formatlistpat=^\s*\d\+[\]:.)}\t ]\s*\\\|^\\s*[-+*]\\s\\+
E518: Unknown option: ]\s*\\|^\\s*[-+*]\\s\\+
:setlocal formatlistpat=^\s*\d\+[\]:.)}\t]\s*\\\|^\\s*[-+*]\\s\\+
(ok, no error when removing the single space, strange...)
(test: numbered bullets do not indent anymore)
(test: dash bullets do not indent either)
(test: without bullets the second line indents like the first - ok)
—
You are receiving this because you commented.
Blanks need to be escaped, that is \ instead of . Did you try the setting at #8794 (comment) ?
—
You are receiving this because you commented.
Singly escaped blanks work, thanks.
When applying #8794 (comment) list/bullet indentation behaves like the default: Numbers work, dash doesn't.
—
You are receiving this because you commented.
bulleted lists as described above: set formatlistpat=^\s*-\s* set breakindent set breakindentopt=list:-1 The above assumes the bulleted lists start with a "-". - Yegappan
I doubt neovim4.4 has this new breakindentopt implemented.
—
You are receiving this because you commented.
I cannot reproduce: With Vim 8.0.1568 and vim --clean -u ~/.vim/viminrc where ~/.vim/viminrc reads
set formatlistpat=^\\s*\\d\\+[\\]:.)}\\t\ ]\\s*\\\|^\\s*[-+*]\\s\\+ set formatoptions+=n set textwidth=68
the line following one starting with - ... is indented after the line break that kicks in after 68 characters.
—
You are receiving this because you commented.
Thanks again, your example via vim --clean indeed work here, using neovim-0.4.4.
So, there must be something else blocking indents for -, +, * in my case. I'll try to track that down.
Feel free to close this issue, if you prefer.
—
You are receiving this because you commented.
Possibly setting setlocal comments-=fb:- could help.
—
You are receiving this because you commented.
I've found out what was blocking your configuration in my case.
In my vimrc there is the global setting
set formatoptions=rqj
and then later, filetype related settings (for txt) get enabled by
au BufNewFile,BufRead,BufWinEnter *.txt call FileTypeTXT()
where FileTypeTXT actually applies your proposed (usually working)
formatoptions etc via setlocal. This way I never had indentation for dashed
bullet lists.
I don't know what's wrong with this way of applying filetype based changes.
I am doing so for a long time now. It seems something gets mixed
up this way.
Anyway, I've found out that replacing the global setting
set formatoptions=rqj
with
set formatoptions+=rqj
helps. Thanks for the awesom help! Super happy to have dashed bullet list indentation now!
—
You are receiving this because you commented.