zsh-users
 help / color / mirror / code / Atom feed
From: Bart Schaefer <schaefer@brasslantern.com>
To: Zsh Users <zsh-users@zsh.org>
Subject: Re: change inside
Date: Fri, 26 Oct 2012 23:38:35 -0700	[thread overview]
Message-ID: <CAH+w=7a9hZs-uw-haD4-V3GWnugiHf037JYnSi62bU4Mh4Sa=Q@mail.gmail.com> (raw)
In-Reply-To: <CAH_OBicRQa-a9Mv_sr6emgObHD11CjF3hxF3M=3LdfTxib8YpA@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1107 bytes --]

On Friday, October 26, 2012, shawn wilson wrote:

> i use vim bindkeys and am quite happy with it. however one feature
> that i use a lot in vim is the 'inside' feature - di, ci, yi, etc. and
> i don't seem to have this on the shell. what's the best way to make
> something like this work and/or could this be implemented to make this
> more like native vim?
>

You will need to create a custom zle widget, or rather, a set of them.  The
basics of finding the "inside" or "around" are the same for all of them, so
you can probably get by with one function that is attached to several
widget names and decides what to do based on the value of $WIDGET.

The first thing the function should do is invoke "zle vi-find-next-char",
this should take care  of reading the target character for the
inside/around boundary.  Then $BUFFER[CURSOR] is that character, so you can
use it to find the previous occurrence of the same.  Then you can set
$MARK, move the cursor to that previous occurence, and call something such
as the kill-region builtin or the narrow-to-region function to implement
the action for $WIDGET.

  reply	other threads:[~2012-10-27  6:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-26 18:06 shawn wilson
2012-10-27  6:38 ` Bart Schaefer [this message]
2012-10-27  9:16   ` shawn wilson
2012-10-27 17:42     ` Bart Schaefer
2012-10-27 18:14       ` Ray Andrews
2012-10-27 20:18         ` shawn wilson
2012-10-27 23:55 ` Takeshi Banse
2012-11-16  9:23 ` zzapper

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='CAH+w=7a9hZs-uw-haD4-V3GWnugiHf037JYnSi62bU4Mh4Sa=Q@mail.gmail.com' \
    --to=schaefer@brasslantern.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).