Monday, October 26, 2020

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

On 2020-10-26, Chris Jones wrote:
> 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?

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

--
--
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/20201026195157.GA32118%40phoenix.

No comments: