Friday, November 22, 2024

Syntax: allow newline but not blank lines in a region

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*\_$\)\@!\)\{-}_}
```

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 `\_.\@!`?

TIA,

/bpj

--
--
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 visit https://groups.google.com/d/msgid/vim_use/CADAJKhD3AO011nDSFp-y7MRg-%2BUd6cmJ7GdgRkks7SXPFHtLow%40mail.gmail.com.

No comments: