Tuesday, July 18, 2017

Re: Searching limited to syntax groups



On Tue, Jul 18, 2017 at 1:01 PM, Tim Chase <vim@tim.thechases.com> wrote:
My digging hasn't been able to turn up anything, but I was hoping for
something that would let me easily search just code or comments to
the exclusion of the other.  Something like (imaging a sequence like
"\%syntax{SyntaxID}" but actual flavor/implementation is negotiable)

  /\%syntax{Comment}customer\c

to only search my comments for "customer\c", excluding all of the
instances of "customer" in my codebase.

Anything obvious I overlooked, or does this require deeper scripting
with search() and then sniffing the resulting SynID value?



I wrote this plugin to address this feature:

SrchRplcHiGrp.vim : Search and/or replace based on a syntax highlight group


It supports the 3 types of visual modes (linewise, block and character).

You can either search for something in the correct highlight group, or you can do search and replaces on those same searches.

The web page has examples of usage.

If you run into something it can't do, I am always open to suggestions.

Enjoy.
David


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