Syntax matching question(s)

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

Syntax matching question(s)

robert h-2
I am creating a vim syntax file for GNU Rec as an exercise in creating a new syntax file.

The things that I need colored are:

%word:
+
word:
# comment

I have the following so far:


" /^%\w+:\s/gm
syntax match recDesc "\v^%\w+:\s"

" recField
" /^\w+:\s/g,
syntax match recField "\v^\w+:\s"

" /^\+\s/gm
syntax match recPlus "^+\s"

" /^#.*/gm
syntax match recComment "^#.*"

The first "recDesc" is not working but the other three (3) are. I was wondering why that is so? I am thinking recDesc and recField are too close in matching.

Also, is there a better regex for the matches?

Thanks for any help and suggestions.

--
Bob

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

robert h-2
On Thursday, July 12, 2018 at 10:51:40 PM UTC-4, Robert wrote:

> I am creating a vim syntax file for GNU Rec as an exercise in creating a new syntax file.
>
> The things that I need colored are:
>
> %word:
> +
> word:
> # comment
>
> I have the following so far:
>
>
> " /^%\w+:\s/gm
> syntax match recDesc "\v^%\w+:\s"
>
> " recField
> " /^\w+:\s/g,
> syntax match recField "\v^\w+:\s"
>
> " /^\+\s/gm
> syntax match recPlus "^+\s"
>
> " /^#.*/gm
> syntax match recComment "^#.*"
>
> The first "recDesc" is not working but the other three (3) are. I was wondering why that is so? I am thinking recDesc and recField are too close in matching.
>
> Also, is there a better regex for the matches?
>
> Thanks for any help and suggestions.
>
> --
> Bob
Had a late work night so did this:

syntax match recField "\v^\w+:\s"
syntax match recPlus "^+\s"
syntax match recComment "^#.*"

syntax region recDesc start="^%" end=":" contains=recField

Everything works. Are those "optimal"?

--
Bob

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

Lifepillar
On 13/07/2018 06:37, Robert wrote:

> On Thursday, July 12, 2018 at 10:51:40 PM UTC-4, Robert wrote:
>> I am creating a vim syntax file for GNU Rec as an exercise in creating a new syntax file.
>>
>> The things that I need colored are:
>>
>> %word:
>> +
>> word:
>> # comment
> […]
> Had a late work night so did this:
>
> syntax match recField "\v^\w+:\s"
> syntax match recPlus "^+\s"
> syntax match recComment "^#.*"
>
> syntax region recDesc start="^%" end=":" contains=recField
>
> Everything works. Are those "optimal"?

According to `:h syn-pattern`, syntax patterns are always interpreted
as if 'magic' is on, so \v can be removed.


Life.


--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

robert h-2
On Friday, July 13, 2018 at 3:05:03 AM UTC-4, Lifepillar wrote:

> On 13/07/2018 06:37, Robert wrote:
> > On Thursday, July 12, 2018 at 10:51:40 PM UTC-4, Robert wrote:
> >> I am creating a vim syntax file for GNU Rec as an exercise in creating a new syntax file.
> >>
> >> The things that I need colored are:
> >>
> >> %word:
> >> +
> >> word:
> >> # comment
> > […]
> > Had a late work night so did this:
> >
> > syntax match recField "\v^\w+:\s"
> > syntax match recPlus "^+\s"
> > syntax match recComment "^#.*"
> >
> > syntax region recDesc start="^%" end=":" contains=recField
> >
> > Everything works. Are those "optimal"?
>
> According to `:h syn-pattern`, syntax patterns are always interpreted
> as if 'magic' is on, so \v can be removed.
>
>
> Life.
If I take off the \v it breaks. So there is something wrong with how I am doing it.

--
Bob

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

Jürgen Krämer-4
Hi,

Robert schrieb am 13.07.2018 um 15:29:

> On Friday, July 13, 2018 at 3:05:03 AM UTC-4, Lifepillar wrote:
>> On 13/07/2018 06:37, Robert wrote:
>>> On Thursday, July 12, 2018 at 10:51:40 PM UTC-4, Robert wrote:
>>>> I am creating a vim syntax file for GNU Rec as an exercise in creating a new syntax file.
>>>>
>>>> The things that I need colored are:
>>>>
>>>> %word:
>>>> +
>>>> word:
>>>> # comment
>>> […]
>>> Had a late work night so did this:
>>>
>>> syntax match recField "\v^\w+:\s"
>>> syntax match recPlus "^+\s"
>>> syntax match recComment "^#.*"
>>>
>>> syntax region recDesc start="^%" end=":" contains=recField
>>>
>>> Everything works. Are those "optimal"?
>>
>> According to `:h syn-pattern`, syntax patterns are always interpreted
>> as if 'magic' is on, so \v can be removed.
>>
>>
>> Life.
>
> If I take off the \v it breaks. So there is something wrong with how I am doing it.
>
> --
> Bob
>

"\v" means "very magic", not "magic". By removing "\v", the "+" in your first pattern
is taken literally, not as a quantifier.

Regards,
Jürgen

--
~
~
~
:wq

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

robert h-2
On Friday, July 13, 2018 at 9:54:42 AM UTC-4, [hidden email] wrote:

> Hi,
>
> Robert schrieb am 13.07.2018 um 15:29:
> > On Friday, July 13, 2018 at 3:05:03 AM UTC-4, Lifepillar wrote:
> >> On 13/07/2018 06:37, Robert wrote:
> >>> On Thursday, July 12, 2018 at 10:51:40 PM UTC-4, Robert wrote:
> >>>> I am creating a vim syntax file for GNU Rec as an exercise in creating a new syntax file.
> >>>>
> >>>> The things that I need colored are:
> >>>>
> >>>> %word:
> >>>> +
> >>>> word:
> >>>> # comment
> >>> […]
> >>> Had a late work night so did this:
> >>>
> >>> syntax match recField "\v^\w+:\s"
> >>> syntax match recPlus "^+\s"
> >>> syntax match recComment "^#.*"
> >>>
> >>> syntax region recDesc start="^%" end=":" contains=recField
> >>>
> >>> Everything works. Are those "optimal"?
> >>
> >> According to `:h syn-pattern`, syntax patterns are always interpreted
> >> as if 'magic' is on, so \v can be removed.
> >>
> >>
> >> Life.
> >
> > If I take off the \v it breaks. So there is something wrong with how I am doing it.
> >
> > --
> > Bob
> >
>
> "\v" means "very magic", not "magic". By removing "\v", the "+" in your first pattern
> is taken literally, not as a quantifier.
>
> Regards,
> Jürgen
>
> --
> ~
> ~
> ~
> :wq
Excellent. That works now.  :)

--
Bob

--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

Lifepillar
>>> On Friday, July 13, 2018 at 3:05:03 AM UTC-4, Lifepillar wrote:

>>>> According to `:h syn-pattern`, syntax patterns are always interpreted
>>>> as if 'magic' is on, so \v can be removed.
>>>
>>> If I take off the \v it breaks. So there is something wrong with how I am doing it.
>>
>> "\v" means "very magic", not "magic". By removing "\v", the "+" in your first pattern
>> is taken literally, not as a quantifier.
>
> Excellent. That works now.  :)

Then I was misinterpreting the documentation. Apparently,
syntax patterns ignore the 'magic' option, but not explicit
flags in the regexp itself. Which makes sense, after all.

Sorry for the noise,
Life.



--
--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Syntax matching question(s)

robert h-2
On Friday, July 13, 2018 at 12:25:29 PM UTC-4, Lifepillar wrote:

> >>> On Friday, July 13, 2018 at 3:05:03 AM UTC-4, Lifepillar wrote:
>
> >>>> According to `:h syn-pattern`, syntax patterns are always interpreted
> >>>> as if 'magic' is on, so \v can be removed.
> >>>
> >>> If I take off the \v it breaks. So there is something wrong with how I am doing it.
> >>
> >> "\v" means "very magic", not "magic". By removing "\v", the "+" in your first pattern
> >> is taken literally, not as a quantifier.
> >
> > Excellent. That works now.  :)
>
> Then I was misinterpreting the documentation. Apparently,
> syntax patterns ignore the 'magic' option, but not explicit
> flags in the regexp itself. Which makes sense, after all.
>
> Sorry for the noise,
> Life.
No no, your post made me try another tweak. I appreciate it.

--
Bob

--
--
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].
For more options, visit https://groups.google.com/d/optout.