Tuesday, May 27, 2014

Re: matching the last part of a url -> and in a syntax file

Eric Smith wrote:
> Tim Chase wrote on Fri-23-May 14 6:32PM
>> \(http|\S*\/\)\@<=\w\+\/\=\S\@!
> Thanks Tim, this works perfectly when tested with matchstr(),
> however I need ti in a syntax file and there it appears to be a
> noop. I tried;
> syn match last_url '\(http\S*\/\)\@<=\w\+\/\=\S\@!'
>
> Any ideas?
>
It should "work perfectly" as is in a syntax file, too. I suspect that
you have some syntax priority issues going on.

* later syntax takes priority over earlier syntax:
syn clear
syn match One 'abc'
syn match Two 'abc'

hi link One Function
hi link Two Identifier

use this with a file containing only "abc". Result: abc is highlighted
using #2 (Identifier). Swap syn-matches One and Two and abc will be
highlighted using #1.

* regions have their own syntax highlighting, and may contain other
syntax recognition.
* nextgroup elevates priority of such syntax

Anyway, its involved. So, may I suggest trying my plugin

http://www.drchip.org/astronaut/vim/index.html#HILINKS

with its :HLT! command, move the cursor over the url: you'll be told
what highlighting groups are in use with the text under the cursor.

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

No comments: