Saturday, February 14, 2015

Re: Search via syntax group

On Fri, Feb 13, 2015 at 1:51 AM, Christian Brabandt <cblists@256bit.org> wrote:
> Am 2015-02-13 07:05, schrieb Dominique Pellé:
>>
>> Justin M. Keyes <justinkz@gmail.com> wrote:
>>
>>> How to search for the next instance of a syntax group?
>>>
>>> For example, say I have this .bashrc file:
>>>
>>> ls foo
>>> rm foo
>>>
>>> "ls" is assigned the "bashStatement" syntax group.
>>>
>>> How do I jump to the next token with that group?
>>>
>>> Is there a way to get the regex expression from a syntax group?
>>>
>>> If not... seems like there should be. A syntax-highlighted buffer has
>>> lots of information encoded in it. There should be a way to leverage
>>> that with motions, /, :s, and :g.
>
>
> Currently it only works for :s by using the hack
> :s/foobar/\=synIDattr(synID(..),'name')=~?'Comment'?'FOOBAR':submatch(0)/
>
>> Maybe the SyntaxMotion plugin is useful to you:
>>
>> http://www.vim.org/scripts/script.php?script_id=2965
>>
>>> Is there a way to get the regex expression from a syntax group?
>>
>>
>> No, but I've been wondering about this too. It could be useful
>> to search by syntax group.
>
>
> It's in the todo list buried. search for \%h and \%s
>
> In fact, this was a reason, why I started hacking Vim source.

Very interesting! Did you think at the time it would be a pretty
straightforward thing? Because that's what I was thinking, so I'm glad
you warned me ... :)

> Unfortunately, it didn't work completly and messed up syntax highlighting
> badly.

Do you have the patch somewhere? It's not linked in the todo.txt.

Justin M. Keyes

--
--
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:

Post a Comment