Prevent lines from being unwrapped when the lines end with a certain character/pattern

14 views
Skip to first unread message

Uday Reddy B

unread,
May 19, 2022, 9:55:57 PM5/19/22
to vim...@googlegroups.com
Hello,

I was trying to find a way to have vim keep lines broken (i.e., not unwrap with auto format) when the lines ended with a certain character. For example, with Latex script, it's desirable to have:

This is a line. \\
Designation \\
Affiliation \\

I have formatoptions set to `tcqan` because I do need auto-formatting everywhere else and in general. However, with such options, vim would auto-format the above to:

This is a line. \\ Designation \\ Affiliation \\

My current approach is to switch into and out of `paste` mode when editing such lines to prevent unwrapping but it'd be convenient if this is automatically taken care of with some setting.

Thanks,
-Uday 

Uday Reddy B

unread,
Jun 2, 2022, 4:39:38 AM6/2/22
to vim...@googlegroups.com

Just another ping on this question to see if there is a way.

-Uday

Christian Brabandt

unread,
Jun 2, 2022, 6:25:21 AM6/2/22
to vim...@googlegroups.com
I don't think this is currently possible, perhaps try to tune the
'formatlistpat' option so that those lines are detect as "lists"

But I would rather ask, if you see such lines, why do you format them in
first place? This may depend on the document however. Not sure if this
is easily possible

Best,
Christian
--
Dass Christus auf eine Hamletische Weise zugrunde ging, und
schlimmer, weil er Menschen um sich berief, die er fallen ließ, da
Hamlet bloß als Individuum perierte.
-- Goethe, Maximen und Reflektionen, Nr. 1285

Uday Reddy B

unread,
Jun 2, 2022, 11:20:14 AM6/2/22
to vim...@googlegroups.com
On Thu, 2 Jun 2022 at 15:55, Christian Brabandt <cbl...@256bit.org> wrote:

On Do, 02 Jun 2022, Uday Reddy B wrote:

>
> Just another ping on this question to see if there is a way.
>
> -Uday
>
> On Fri, 20 May 2022 at 07:25, Uday Reddy B <uday...@gmail.com> wrote:
>
>     Hello,
>
>     I was trying to find a way to have vim keep lines broken (i.e., not unwrap with auto format) when the lines ended with a certain character. For example, with Latex script, it's desirable to have:
>
>     This is a line. \\
>     Designation \\
>     Affiliation \\
>
>     I have formatoptions set to `tcqan` because I do need auto-formatting everywhere else and in general. However, with such options, vim would auto-format the above to:
>
>     This is a line. \\ Designation \\ Affiliation \\
>
>     My current approach is to switch into and out of `paste` mode when editing such lines to prevent unwrapping but it'd be convenient if this is automatically taken care of with some setting.

I don't think this is currently possible, perhaps try to tune the
'formatlistpat' option so that those lines are detect as "lists"

Thank you for suggesting this - I'll explore it.
 

But I would rather ask, if you see such lines, why do you format them in
first place? This may depend on the document however. Not sure if this
is easily possible

I don't manually/explicitly format them - I have 'a' set in formatoptions. This basically means if I get my cursor in and around those lines while being in the 'insert' mode, those are going to get formatted (unwrapped) and lead to the undesired output.

Thanks,
-Uday

 

Best,
Christian
--
Dass Christus auf eine Hamletische Weise zugrunde ging, und
schlimmer, weil er Menschen um sich berief, die er fallen ließ, da
Hamlet bloß als Individuum perierte.
                -- Goethe, Maximen und Reflektionen, Nr. 1285

--
--
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+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20220602102513.GC4071194%40256bit.org.
Reply all
Reply to author
Forward
0 new messages