Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: change inside

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.

Messages sorted by: Reverse Date, Date, Thread, Author