Re: Syntax: allow newline but not blank lines in a region

Doug Kearns <[email protected]>
Newsgroups gmane.editors.vim
Message-ID <CAJ1uvoB5GPjE1RKY4wQkRW_zawUvFxnYWDHgOdOQ8tgkMdU+pw@mail.gmail.com>
On Sat, 23 Nov 2024 at 04:28, BPJ <[email protected]> wrote:

> I have a syntax for a markup language where certain delimited constructs
> allow single newlines but not blank lines, i.e. this is OK
>
> ``` markup
> {_foo
> bar_}
> ```
>
> but this is not OK
>
> ``` markup
> {_foo
>
> bar_}
> ```
>
> is there any way to set up a region so that it behaves like this? I tried
> `oneline` plus a contained `syn match` which matches a newline not preceded
> or followed by a blank line but no luck!
>
> I get the behavior I want with a `syn match` with this pattern
>
> ``` pattern
> {_\%([^\n]\|\%(\_^\s*\)\@<!\n\%(\s*\_$\)\@!\)\{-}_}
> ```
>

Does something like this work?

:syn region foobar start="{_" end="_}" end="$" skip="\n\s*\S"


> but then highlighting obviosly doesn't kick in until I type the closing
> delimiter so I would prefer a region.
>
> Also is there a better way to match the start or end of the file than
> `\_.\@<!` and `\_.\@!`?
>

:help \%^

Regards,
Doug

-- 
-- 
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 [email protected].
To view this discussion visit https://groups.google.com/d/msgid/vim_use/CAJ1uvoB5GPjE1RKY4wQkRW_zawUvFxnYWDHgOdOQ8tgkMdU%2Bpw%40mail.gmail.com.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.