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

Re: copy "real" previous word

On Mon, 31 Mar 2014 14:29:25 +0000 (UTC)
zzapper <david@xxxxxxxxxxxxxx> wrote:
> bindkey -M viins '^O' copy-prev-shell-word
> cp fred.php old_<Control-O>
> gives me
> cp fred.php old_old_  
> when I wanted
> cp fred.php old_fred.php

Try using the user-defined widget copy-earlier-word --- it still starts
by copying the immediately preceeding word chunk, but you can repeat it
to copy what's before that.  So you just need to type ^O twice.

It's an interesting (but not *that* interesting) student excercise to
make a widget to do exactly what (I think) you want:  test if there's
white space before the cursor, if so call copy-earlier-word once, else
call it twice.  For bonus points (now this is getting a bit
interesting) check if the whitespace might be part of an uncompleted
quoted argument.

(Second time in a week I've found myself getting confused between "word"
and "argument"...)


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