Monday, November 11, 2019

Re: Highlighting parenthesized blocks

On Tue, Nov 12, 2019 at 1:20 AM Chris Jones <cjns1989@gmail.com> wrote:
>
> I would need to highlight blocks of text delimited by opening/closing parentheses of any given type (regular, square, curly, squiggly, etc.).
>
> For instance:
>
> '… this is some text (here is a parenthesized block) that I would like to stand out.'
>
> then a few lines down:
>
> '… more text an here again (I have another parenthesized block) that I also want highlighted.
>
> This one is simple enough… after I ':set hls' and search via '/(.*)' the parenthesized text is matched by the regex and highlighted as specified by the color scheme.
>
> It gets a little less obvious when some of the parenthesized blocks may span more than a single lines.
>
> Is there any way this can be done via vim regular expressions?
>
> N.B. I know about the matching paren thingy but that is not what I want — I want the whole 'opening paren+text+closing paren' to stand out.
>
> The context is that I have some rather large markdown files to inspect with numerous inline footnotes whose syntax is:
>
> '^[ footnote ]'
>
> and I am looking for a reliable way to make such footnotes stand out so I can (1) spot them at a glance and (2) easily check that they are syntaxically AOK.
>
> To keep it simple I am not concerned about the possiblity of having square bracketed text within the footnotes.
>
> Thanks,
>
> CJ

This might not be exactly what you're asking for but it has the
advantage of working out of the box:

By default (i.e. when the matchparen global plugin is enabled, which
is the default), when the cursor is on a bracket, Vim highlights that
and the matching opposite bracket (if the latter is visible); and even
if they are too far from each other to be seen together, hitting % in
Normal mode jumps from one to the other. Which brackets are regarded
as "paired" depends on the 'matchpairs' option, whose default is
(:),{:},[:] — it is possible to match also < with > by adding

set matchpairs+=<:>

in one's vimrc; but this matching works only if the starting and
ending brackets are different: you can (by a proper setting) have it
match « with », or " (typographic "double-6" quote) with "
(typographic "double-9" quote) but not " with itself.

Matching is done recursively (skipping over embedded bracket pairs),
and, if the matchit plugin is enabled (which is the default) a bracket
within quotation marks won't be matched with a bracket outside of any
quote.

Best regards,
Tony.

--
--
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/CAJkCKXuOftmbrifFnnWE_bK4dC7ZTwuUGCS8hn59u2y82yKZFg%40mail.gmail.com.

No comments: