zsh-users
 help / color / mirror / code / Atom feed
From: "Jérémie Roquet" <arkanosis@gmail.com>
To: shawn wilson <ag4ve.us@gmail.com>
Cc: Zsh Users <zsh-users@zsh.org>
Subject: Re: Match paren
Date: Fri, 16 Aug 2013 16:51:38 +0200	[thread overview]
Message-ID: <CAFOazAP2_kSOjQV9z2JVoVJ9Xbn5f-U3gWJixZCZpRRQfUHxiQ@mail.gmail.com> (raw)
In-Reply-To: <CAH_OBicvEpj2wZTGo9LCa59sh7aipeR-G807P3D9pN=4X783QA@mail.gmail.com>

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


      parent reply	other threads:[~2013-08-16 14:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-16 14:36 shawn wilson
2013-08-16 14:48 ` Aaron Schrab
2013-08-16 14:51 ` Jérémie Roquet [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAFOazAP2_kSOjQV9z2JVoVJ9Xbn5f-U3gWJixZCZpRRQfUHxiQ@mail.gmail.com \
    --to=arkanosis@gmail.com \
    --cc=ag4ve.us@gmail.com \
    --cc=zsh-users@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).