Disable automatic indentation of a block that starts with number+period after issuing gw-type commands

17 views
Skip to first unread message

Chris Jones

unread,
Oct 26, 2020, 2:09:51 PM10/26/20
to vim...@googlegroups.com
I would like to disable this feature.

I have text that looks like this:

| 1234. Reprehenderit voluptatem similique quibusdam
| voluptate voluptas.
| Et repellat autem aspernatur sunt aperiam id necessitatibus
| laudantium. Rerum
| eum
| libero excepturi cum illum aliquam rerum aut. Amet atque dicta aut et voluptatem.

In order to tidy it up a bit, with the cursor anywhere inside this block I hit
'gwap' or such and I get this:

| 1234. Reprehenderit voluptatem similique quibusdam voluptate voluptas.
| Et repellat autem aspernatur sunt aperiam id necessitatibus
| laudantium. Rerum eum libero excepturi cum illum aliquam rerum
| aut. Amet atque dicta aut et voluptatem.

Something in vim believes that this block is item #1234 in a numbered
list and indents everything following the first line so that it ends up
aligned with the text in line 1. Nice feature but in this instance this
is not what I want.

This is what I want:

| 1234. Reprehenderit voluptatem similique quibusdam voluptate voluptas. Et
| repellat autem aspernatur sunt aperiam id necessitatibus laudantium.
| Rerum eum libero excepturi cum illum aliquam rerum aut. Amet atque dicta
| aut et voluptatem.

Current indentation settings (that I am aware) I have turned off:

| nocindent
| noautoindent
| nosmartindent
| indentexpr=
| indentkeys=

I have tried issuing:

| :filetype indent off

All to no avail.

The only way I have been able to disable this feature is by manually
removing the period, reflowing the block, and adding back the period.

Since the period seems to be causing the problem I have started to
suspect that the period is defined somwhere in vim's wagonload of
'settable' options? So far I have not been able to find where.

This is a markdown file with some ~1500 such blocks (OCR'd material
originally). I do not want vim to make assumptions or prettify it in any
way because it is later fed to a toolchain that takes care of such
aspects.

Is there any way I can make vim stop doing this... apart from writing
some kind of macro/function that will remove & back the period... and
take care of the reflowing in between?

Thanks,

CJ

Gary Johnson

unread,
Oct 26, 2020, 3:52:31 PM10/26/20
to vim...@googlegroups.com
It looks like you have the 'n' flag in 'formatoptions' set. Try
executing this,

:set fo-=n

and reformatting that paragraph. If that's it, you can find the
last place where 'formatoptions' was set with

:verbose set fo?

Hopefully, that will be the place where 'n' was added and you can
fix it. Also see

:help 'fo'
:help fo-table

I usually have 'n' included in my 'formatoptions', so I run into
this problem occasionally. When I do, I shift the second line left
(<<), then reformat the rest of the paragraph (gq}).

HTH,
Gary

Chris Jones

unread,
Oct 27, 2020, 4:20:45 PM10/27/20
to vim...@googlegroups.com
Removing the 'n' from that fo collection did the trick!

With the file I'm currently cleaning up this was driving me insane.

The place where it was set...? you guessed right... my own ~/.vimrc...!

Cleaning up that mess is about 20 years overdue...

Thanks,

CJ
Reply all
Reply to author
Forward
0 new messages