zsh-users
 help / color / mirror / code / Atom feed
* Match paren
@ 2013-08-16 14:36 shawn wilson
  2013-08-16 14:48 ` Aaron Schrab
  2013-08-16 14:51 ` Jérémie Roquet
  0 siblings, 2 replies; 3+ messages in thread
From: shawn wilson @ 2013-08-16 14:36 UTC (permalink / raw)
  To: Zsh Users

Has anyone made a script or omz plugin that visually highlights
matching parens, brackets, and curleys? I know this is being done
somehow as % works to move between them. However, I'd like to see the
match when I hover over it.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Match paren
  2013-08-16 14:36 Match paren shawn wilson
@ 2013-08-16 14:48 ` Aaron Schrab
  2013-08-16 14:51 ` Jérémie Roquet
  1 sibling, 0 replies; 3+ messages in thread
From: Aaron Schrab @ 2013-08-16 14:48 UTC (permalink / raw)
  To: shawn wilson; +Cc: Zsh Users

At 10:36 -0400 16 Aug 2013, shawn wilson <ag4ve.us@gmail.com> wrote:
>Has anyone made a script or omz plugin that visually highlights
>matching parens, brackets, and curleys? I know this is being done
>somehow as % works to move between them. However, I'd like to see the
>match when I hover over it.

The zsh-syntax-highlighting project will do that along with other types 
of syntax highlighting.

https://github.com/zsh-users/zsh-syntax-highlighting


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Match paren
  2013-08-16 14:36 Match paren shawn wilson
  2013-08-16 14:48 ` Aaron Schrab
@ 2013-08-16 14:51 ` Jérémie Roquet
  1 sibling, 0 replies; 3+ messages in thread
From: Jérémie Roquet @ 2013-08-16 14:51 UTC (permalink / raw)
  To: shawn wilson; +Cc: Zsh Users

Hi,

2013/8/16 shawn wilson <ag4ve.us@gmail.com>:
> Has anyone made a script or omz plugin that visually highlights
> matching parens, brackets, and curleys? I know this is being done
> somehow as % works to move between them. However, I'd like to see the
> match when I hover over it.

The following code highlights the matching symbols when you type them.
Unless I'm mistaken, it was originally written by Oliver Kiddle.

function highlight-paren()
{
    local i nested=1

    typeset -A match

    match=(
        \) \(
        \] \[
        \} \{
        \" \"
        \' \'
        \` \`
     )

    zle self-insert

    for ((i=$((CURSOR - 1)); i; --i)) {
        [[ $BUFFER[$i] = $match[$KEYS] ]] && (( ! --nested )) && break
        [[ $BUFFER[$i] == $KEYS ]] && (( ++nested ))
    }

    region_highlight=("$((i-1)) $i standout")
    zle -R
    read -kt 1 && zle -U "$REPLY"
    region_highlight=()
}
zle -N highlight-paren

Best regards,

-- 
Jérémie


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-08-16 14:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-16 14:36 Match paren shawn wilson
2013-08-16 14:48 ` Aaron Schrab
2013-08-16 14:51 ` Jérémie Roquet

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).