zsh-users
 help / color / mirror / code / Atom feed
* copy "real" previous word
@ 2014-03-31 14:29 zzapper
  2014-03-31 14:47 ` Peter Stephenson
  0 siblings, 1 reply; 3+ messages in thread
From: zzapper @ 2014-03-31 14:29 UTC (permalink / raw)
  To: zsh-users

Hi
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

also tried 
bindkey -M viins '^O' copy-prev-word

-- 
zzapper
https://twitter.com/dailyzshtip


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

* Re: copy "real" previous word
  2014-03-31 14:29 copy "real" previous word zzapper
@ 2014-03-31 14:47 ` Peter Stephenson
  2014-03-31 15:11   ` zzapper
  0 siblings, 1 reply; 3+ messages in thread
From: Peter Stephenson @ 2014-03-31 14:47 UTC (permalink / raw)
  To: zsh-users

On Mon, 31 Mar 2014 14:29:25 +0000 (UTC)
zzapper <david@rayninfo.co.uk> 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"...)

pws


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

* Re: copy "real" previous word
  2014-03-31 14:47 ` Peter Stephenson
@ 2014-03-31 15:11   ` zzapper
  0 siblings, 0 replies; 3+ messages in thread
From: zzapper @ 2014-03-31 15:11 UTC (permalink / raw)
  To: zsh-users

Peter Stephenson <p.stephenson@samsung.com> wrote in 
news:20140331154748.1dc7cf27@pwslap01u.europe.root.pri:

>  copy-earlier-word 

thanks the cycle through is useful as well

autoload -Uz copy-earlier-word
zle -N copy-earlier-word
bindkey -M viins '^O' copy-earlier-word 

-- 
zzapper
https://twitter.com/dailyzshtip


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

end of thread, other threads:[~2014-03-31 15:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31 14:29 copy "real" previous word zzapper
2014-03-31 14:47 ` Peter Stephenson
2014-03-31 15:11   ` zzapper

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).