syn region start="first line" end="first line"

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

syn region start="first line" end="first line"

Oskar Sharipov
Hi!

I'm doing a syntax file for my own silly made up filetype. The first
line of a file is always tag-section and I want to highlight it. There
is no special pattern for searching by regexp --- the aim is to
highlight the first line ALWAYS.

For example, in this context:

        Blah-blah

        foo, bar,
        one, two, three.

only "Blah-blah" must be captured for highlighting with `hi def` later.

Could I use `syn region` for that purpose and how? If not what're other
ways to do that?

--
Oskar Sharipov
site (might be unpaid and cancelled): oskarsh.ru
e-mail (replace asterisk with dot): oskarsh at riseup * net
secondary e-mail (same): oskar * sharipov at tutanota * org
gpg fingerprint: BAC3 F049 748A D098 A144  BA89 0DC4 EA75 714C 75B5

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/X/XCDTNOERBlaN4x%40piggy.

signature.asc (235 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: syn region start="first line" end="first line"

Charles Campbell-2
Oskar Sharipov wrote:

> Hi!
>
> I'm doing a syntax file for my own silly made up filetype. The first
> line of a file is always tag-section and I want to highlight it. There
> is no special pattern for searching by regexp --- the aim is to
> highlight the first line ALWAYS.
>
> For example, in this context:
>
> Blah-blah
>
> foo, bar,
> one, two, three.
>
> only "Blah-blah" must be captured for highlighting with `hi def` later.
>
> Could I use `syn region` for that purpose and how? If not what're other
> ways to do that?
>
Hope the attached file helps. It uses syn match with a pattern using \%1l .

Regards,
Chip Campbell

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f89dfadb-c1c5-27b2-7923-93603ec5cf7c%40drchip.org.

firstlineonly.vim (300 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: syn region start="first line" end="first line"

Oskar Sharipov
On Wed, Jan 06, 2021 at 09:35:42PM -0500, Charles Campbell wrote:
> syn match FirstLine '^\%1l.*$'

Thanks, Charles Campbell! That's what I needed.

--
Oskar Sharipov
gpg fingerprint: BAC3 F049 748A D098 A144  BA89 0DC4 EA75 714C 75B5

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/X/bibQDiVTFqSmcM%40piggy.

signature.asc (235 bytes) Download Attachment