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

9 views
Skip to first unread message

Oskar Sharipov

unread,
Jan 6, 2021, 7:56:12 PM1/6/21
to v...@vim.org
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
signature.asc

Charles Campbell

unread,
Jan 6, 2021, 9:35:50 PM1/6/21
to Oskar Sharipov, vim...@googlegroups.com
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
firstlineonly.vim

Oskar Sharipov

unread,
Jan 7, 2021, 5:29:40 AM1/7/21
to vim...@googlegroups.com
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
signature.asc
Reply all
Reply to author
Forward
0 new messages