Wednesday, January 6, 2021

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

if exists("b:current_syntax")
finish
endif

syn clear
set ft=firstlineonly
syn match FirstLine '^\%1l.*$'

if !exists("did_firstlineonly_inits")
let did_firstlineonly_inits= 1
hi link FirstLine Comment
endif

" vim:
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/f89dfadb-c1c5-27b2-7923-93603ec5cf7c%40drchip.org.

No comments:

Post a Comment