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

Re: summary of ^^^ substitition



zzapper wrote:
> I believe the ^^^ substitute mechanism is syntactic sugar for:-
> > r old=new

Essentially; it's implemented slightly more efficiently.

> The uses I know:-
> 
> ^fred^joe             # edit previous command replace fred by joe
> ^str1^str2^:u:p       # replace str1 by str2 change case and just display
> ^fred^&&              # replace fred by fredfred
> 
> Any more? and where should I look in the man pages?
>
> There was some talk about adding a global modifier?

The HISTORY EXPANSION section of the zshexpn manual now has a paragraph

   The character sequence '^foo^bar' (where '^'  is  actually  the  second
   character of the histchars parameter) repeats the last command, replac-
   ing the string foo with bar.  More precisely, the sequence  '^foo^bar^'
   is synonymous with '!!:s^foo^bar^', hence other modifiers (see the sec-
   tion  'Modifiers')  may  follow  the   final   '^'.    In   particular,
   '^foo^bar:G' performs a global substitution.

% echo foo is not food
foo is not food
% ^foo^bar^:G
% echo bar is not bard

This is only in 4.3.

-- 
Peter Stephenson <pws@xxxxxxx>                  Software Engineer
CSR PLC, Churchill House, Cambridge Business Park, Cowley Road
Cambridge, CB4 0WZ, UK                          Tel: +44 (0)1223 692070


To access the latest news from CSR copy this link into a web browser:  http://www.csr.com/email_sig.php



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